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

'insert_register' doesn't handle register name correctly #1751

Merged
merged 1 commit into from
Mar 13, 2022
Merged

'insert_register' doesn't handle register name correctly #1751

merged 1 commit into from
Mar 13, 2022

Conversation

shnarazk
Copy link
Contributor

@shnarazk shnarazk commented Mar 5, 2022

Problem

insert_register ignores register name and always pastes the last yanked text.

  • version: 0.6(nixpkg) and f1e90ac on the main branch

Proposal

  • Set register name to cx.register instead of cx.editor.selected_register.

plus:

  • Update cx.editor.autoinfo to display register contents, like select_register.
  • Call paste_after instead of paste_before; the position of the pasted text matches other editors.

Now it seems to work well.

helix-term/src/commands.rs Outdated Show resolved Hide resolved
@shnarazk shnarazk requested a review from archseer March 12, 2022 02:32
@archseer
Copy link
Member

Hmm I think you're actually right: paste before and paste after selection aren't quite what you want here, it should be inserting at cursor.

You could add a Paste::Cursor value to the enum then use range.cursor(...)

(Paste::Before, false) => range.from(),
(ignore the linewise value)

 - set register name correctly
 - use autoinfo to display register contents
 - call `paste` with `Paste::Cursor`
@shnarazk
Copy link
Contributor Author

After reading your comment and after re-evaluation, I convinced Pos::Cursor is required when a text in a register contains newlines.
I've revised as you suggested. It seems to work well with text with newlines.
(Commits were squashed.)

Copy link
Member

@archseer archseer left a comment

Choose a reason for hiding this comment

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

Thanks! 🎉

Nice to see more japanese users :) 🇯🇵

@archseer archseer merged commit 05161aa into helix-editor:master Mar 13, 2022
@shnarazk
Copy link
Contributor Author

🎉 🎉 Thank you too from far east 😄

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.

2 participants