Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix copy to the linux system clipboard #120

Merged
merged 6 commits into from
Oct 20, 2024

Conversation

Distantoff
Copy link
Contributor

@Distantoff Distantoff commented Oct 18, 2024

Hello! Thank you for your project, I liked it, but immediately I came across that the clipboard of the system was not working. I found the reason why this happens - the instance of arboard clipboard must run throughout the lifetime of the entire program..
Instead of copying text, signals are sent in the vim module, which are processed in the app, as well as components.

Copy link
Owner

@achristmascarl achristmascarl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thank you for the contribution @Distantoff, and for the research into the cause!

i left one small piece of feedback, but other than that everything else looks good, and will merge it after doing some testing

src/components/editor.rs Show resolved Hide resolved
@achristmascarl
Copy link
Owner

(you can ignore this bot's feedback for now, it's just to flag anything else i might want to look at)

@greptileai

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This pull request addresses the Linux system clipboard functionality issue in the rainfrog project. The changes ensure that the arboard clipboard instance persists throughout the application's lifecycle.

  • Implemented CopyData action in src/app.rs for centralized clipboard handling
  • Modified src/components/editor.rs to use action-based clipboard operations
  • Refactored src/vim.rs to send clipboard actions instead of direct clipboard access

Security implications: The changes don't introduce new security risks, as they primarily modify internal clipboard handling.

Performance: The modifications should have minimal impact on performance, with a slight increase in memory usage due to the persistent clipboard instance.

3 file(s) reviewed, 8 comment(s)
Edit PR Review Bot Settings | Greptile

src/app.rs Show resolved Hide resolved
src/app.rs Show resolved Hide resolved
src/components/editor.rs Show resolved Hide resolved
src/components/editor.rs Show resolved Hide resolved
@@ -115,6 +117,7 @@ impl<'a> Editor<'a> {

impl<'a, DB: Database + DatabaseQueries> Component<DB> for Editor<'a> {
fn register_action_handler(&mut self, tx: UnboundedSender<Action>) -> Result<()> {
self.vim_state.register_action_handler(self.command_tx.clone())?;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: self.command_tx is None here, so this call will always fail

src/vim.rs Show resolved Hide resolved
Comment on lines 107 to +109
pub fn with_pending(self, pending: Input) -> Self {
Self { mode: self.mode, pending }
Self { mode: self.mode, pending, command_tx: None }
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: command_tx is set to None here, potentially losing the original transmitter

src/vim.rs Show resolved Hide resolved
@achristmascarl
Copy link
Owner

hm after taking another look at vim_state and the command_tx registration, i think it might be better to always initialize vim_state with a pointer to a function in editor.rs that does the message sending instead since it already has the command_tx initialized.

i can make the edits directly after doing some testing if you dont mind

@Distantoff
Copy link
Contributor Author

hm after taking another look at vim_state and the command_tx registration, i think it might be better to always initialize vim_state with a pointer to a function in editor.rs that does the message sending instead since it already has the command_tx initialized.

i can make the edits directly after doing some testing if you dont mind

editor.rs

Yes of course! Perhaps this is the best solution

@achristmascarl
Copy link
Owner

i couldn't get it to work with giving the vim_state a function pointer or closure to a function in editor, so i'll stick with your approach of having the command_tx registered in vim_state :)

did some profiling and cloning the command_tx every transition doesnt have any performance impact

@Distantoff
Copy link
Contributor Author

i couldn't get it to work with giving the vim_state a function pointer or closure to a function in editor, so i'll stick with your approach of having the command_tx registered in vim_state :)

did some profiling and cloning the command_tx every transition doesnt have any performance impact

Yes, cloning command_tx as far as I know just copies the reference, so the number of sender can be created a lot

Copy link
Owner

@achristmascarl achristmascarl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

closes #83 (hopefully)

@achristmascarl achristmascarl linked an issue Oct 20, 2024 that may be closed by this pull request
@achristmascarl achristmascarl merged commit 6ee8551 into achristmascarl:main Oct 20, 2024
8 checks passed
Copy link

Included in release v0.2.8

tmeijn pushed a commit to tmeijn/dotfiles that referenced this pull request Oct 22, 2024
This MR contains the following updates:

| Package | Update | Change |
|---|---|---|
| [achristmascarl/rainfrog](https://github.com/achristmascarl/rainfrog) | patch | `v0.2.7` -> `v0.2.8` |

MR created with the help of [el-capitano/tools/renovate-bot](https://gitlab.com/el-capitano/tools/renovate-bot).

**Proposed changes to behavior should be submitted there as MRs.**

---

### Release Notes

<details>
<summary>achristmascarl/rainfrog (achristmascarl/rainfrog)</summary>

### [`v0.2.8`](https://github.com/achristmascarl/rainfrog/releases/tag/v0.2.8)

[Compare Source](achristmascarl/rainfrog@v0.2.7...v0.2.8)

<!-- Release notes generated using configuration in .github/release.yml at v0.2.8 -->

#### What's Changed

-   fix copy to the linux system clipboard by [@&#8203;Distantoff](https://github.com/Distantoff) in achristmascarl/rainfrog#120

#### New Contributors

-   [@&#8203;Distantoff](https://github.com/Distantoff) made their first contribution in achristmascarl/rainfrog#120

**Full Changelog**: achristmascarl/rainfrog@v0.2.7...v0.2.8

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied.

♻ **Rebasing**: Whenever MR becomes conflicted, or you tick the rebase/retry checkbox.

🔕 **Ignore**: Close this MR and you won't be reminded about this update again.

---

 - [ ] <!-- rebase-check -->If you want to rebase/retry this MR, check this box

---

This MR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate).
<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40NDAuNyIsInVwZGF0ZWRJblZlciI6IjM3LjQ0MC43IiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJSZW5vdmF0ZSBCb3QiXX0=-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

fix X11 clipboard timeout on linux
2 participants