From 354b822d21ca82dc6a761d67cd92e4e00f855da5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bla=C5=BE=20Hrastnik?= Date: Sat, 15 May 2021 10:46:59 +0900 Subject: [PATCH] Fix crash on xa if we were on the last line. --- helix-term/src/commands.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 3476e9017..fc3c25610 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); }