aboutsummaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-05-15 01:46:59 +0000
committerBlaž Hrastnik2021-05-15 01:50:36 +0000
commit354b822d21ca82dc6a761d67cd92e4e00f855da5 (patch)
treee044e766bf456a167258c7156738a0ea1c086e63 /helix-term/src
parentfae2127a119b6aebcb87056d01de47e84be084ed (diff)
Fix crash on xa<Enter> if we were on the last line.
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs11
1 files changed, 11 insertions, 0 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 3476e901..fc3c2561 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -823,6 +823,17 @@ pub fn append_mode(cx: &mut Context) {
graphemes::next_grapheme_boundary(text, range.to()), // to() + next char
)
});
+
+ let end = text.len_chars();
+
+ if selection.iter().any(|range| range.head == end) {
+ let transaction = Transaction::change(
+ doc.text(),
+ vec![(end, end, Some(Tendril::from_char('\n')))].into_iter(),
+ );
+ doc.apply(&transaction, view.id);
+ }
+
doc.set_selection(view.id, selection);
}