summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-03-30 09:27:45 +0000
committerBlaž Hrastnik2021-03-30 09:31:56 +0000
commite166da2ab051279f3086e0942f6b7adb1a641a84 (patch)
tree740c82122e39b023c472f9dd9ee3873c777c0a9f /helix-term/src/commands.rs
parent1b5316ea74845a23bebf492dd091fd1fc3a8dcaa (diff)
fix: A (append to line) was inserting before last char.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 8dc69544..7233f1da 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -922,18 +922,25 @@ fn selection_lines(doc: &Rope, selection: &Selection) -> Vec<usize> {
// I inserts at the start of each line with a selection
pub fn prepend_to_line(cx: &mut Context) {
+ move_line_start(cx);
let doc = cx.doc();
enter_insert_mode(doc);
-
- move_line_start(cx);
}
// A inserts at the end of each line with a selection
pub fn append_to_line(cx: &mut Context) {
+ move_line_end(cx);
+
let doc = cx.doc();
enter_insert_mode(doc);
- move_line_end(cx);
+ // offset by another 1 char since move_line_end will position on the last char, we want to
+ // append past that
+ let selection = doc.selection().transform(|range| {
+ let pos = range.head + 1;
+ Range::new(pos, pos)
+ });
+ doc.set_selection(selection);
}
// o inserts a new line after each line with a selection