Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 604d6924..44633741 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -4206,6 +4206,7 @@ pub mod insert {
None
};
+ let mut last_pos = 0;
let mut transaction = Transaction::change_by_selection(contents, selection, |range| {
// Tracks the number of trailing whitespace characters deleted by this selection.
let mut chars_deleted = 0;
@@ -4227,7 +4228,8 @@ pub mod insert {
let (from, to, local_offs) = if let Some(idx) =
text.slice(line_start..pos).last_non_whitespace_char()
{
- let first_trailing_whitespace_char = (line_start + idx + 1).min(pos);
+ let first_trailing_whitespace_char = (line_start + idx + 1).clamp(last_pos, pos);
+ last_pos = pos;
let line = text.line(current_line);
let indent = match line.first_non_whitespace_char() {