Skip to content

Commit

Permalink
Fix: insert_register (#1751)
Browse files Browse the repository at this point in the history
- set register name correctly
 - use autoinfo to display register contents
 - call `paste` with `Paste::Cursor`
  • Loading branch information
shnarazk authored Mar 13, 2022
1 parent e8cc7ac commit 05161aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions helix-term/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3038,6 +3038,7 @@ fn yank_main_selection_to_primary_clipboard(cx: &mut Context) {
enum Paste {
Before,
After,
Cursor,
}

fn paste_impl(
Expand Down Expand Up @@ -3084,6 +3085,8 @@ fn paste_impl(
(Paste::Before, false) => range.from(),
// paste append
(Paste::After, false) => range.to(),
// paste at cursor
(Paste::Cursor, _) => range.cursor(text.slice(..)),
};
(pos, pos, values.next())
});
Expand Down Expand Up @@ -3829,10 +3832,12 @@ fn select_register(cx: &mut Context) {
}

fn insert_register(cx: &mut Context) {
cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
cx.on_next_key(move |cx, event| {
if let Some(ch) = event.char() {
cx.editor.selected_register = Some(ch);
paste_before(cx);
cx.editor.autoinfo = None;
cx.register = Some(ch);
paste(cx, Paste::Cursor);
}
})
}
Expand Down

0 comments on commit 05161aa

Please sign in to comment.