on master help sign in
Fix: insert_register (#1751)

- set register name correctly - use autoinfo to display register contents - call `paste` with `Paste::Cursor`

commit05161aa85e14ec6cd84234d724639289027284fe authorNarazaki Shuji <shujinarazaki@protonmail.com> dateSun 13 Mar 2022, 17:23 (5 years ago) parente8cc7ac
1 file changed+7−2
helix-term/src/commands.rs+7−2
helix-term/src/commands.rs+7−2
@@ -3038,6 +3038,7 @@ fn yank_main_selection_to_primary_clipboard(cx: &mut Context) {
30383038enum Paste {
30393039 Before,
30403040 After,
3041+ Cursor,
30413042}
30423043
30433044fn paste_impl(
@@ -3084,6 +3085,8 @@ fn paste_impl(
30843085 (Paste::Before, false) => range.from(),
30853086 // paste append
30863087 (Paste::After, false) => range.to(),
3088+ // paste at cursor
3089+ (Paste::Cursor, _) => range.cursor(text.slice(..)),
30873090 };
30883091 (pos, pos, values.next())
30893092 });
@@ -3829,10 +3832,12 @@ fn select_register(cx: &mut Context) {
38293832}
38303833
38313834fn insert_register(cx: &mut Context) {
3835+ cx.editor.autoinfo = Some(Info::from_registers(&cx.editor.registers));
38323836 cx.on_next_key(move |cx, event| {
38333837 if let Some(ch) = event.char() {
3834− cx.editor.selected_register = Some(ch);
3835− paste_before(cx);
3838+ cx.editor.autoinfo = None;
3839+ cx.register = Some(ch);
3840+ paste(cx, Paste::Cursor);
38363841 }
38373842 })
38383843}