on master help sign in
fix: A (append to line) was inserting before last char.
e166da2Blaž Hrastnik
helix-term/src/commands.rs+10−3
@@ -922,18 +922,25 @@ fn selection_lines(doc: &Rope, selection: &Selection) -> Vec<usize> {
922
922
923// I inserts at the start of each line with a selection
923// I inserts at the start of each line with a selection
924pub fn prepend_to_line(cx: &mut Context) {
924pub fn prepend_to_line(cx: &mut Context) {
925+ move_line_start(cx);
925 let doc = cx.doc();
926 let doc = cx.doc();
926 enter_insert_mode(doc);
927 enter_insert_mode(doc);
927−
928− move_line_start(cx);
929}
928}
930
929
931// A inserts at the end of each line with a selection
930// A inserts at the end of each line with a selection
932pub fn append_to_line(cx: &mut Context) {
931pub fn append_to_line(cx: &mut Context) {
932+ move_line_end(cx);
933+
933 let doc = cx.doc();
934 let doc = cx.doc();
934 enter_insert_mode(doc);
935 enter_insert_mode(doc);
935
936
936− move_line_end(cx);
937+ // offset by another 1 char since move_line_end will position on the last char, we want to
938+ // append past that
939+ let selection = doc.selection().transform(|range| {
940+ let pos = range.head + 1;
941+ Range::new(pos, pos)
942+ });
943+ doc.set_selection(selection);
937}
944}
938
945
939// o inserts a new line after each line with a selection
946// o inserts a new line after each line with a selection