From b1cb98283dacf98fb15e5fbcdb12d0be4161190b Mon Sep 17 00:00:00 2001 From: Gokul Soumya Date: Fri, 18 Jun 2021 14:20:25 +0530 Subject: Fix indent regression issue with o, O Indents were no longer respected with `o` and `O`. Using counts resulted in multiple cursors in the same line instead of cursors on each line. Introduced by 47d2e3ae --- helix-term/src/commands.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'helix-term') diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs index 9b916a5e..a8610223 100644 --- a/helix-term/src/commands.rs +++ b/helix-term/src/commands.rs @@ -1641,7 +1641,8 @@ fn open(cx: &mut Context, open: Open) { true, ); let indent = doc.indent_unit().repeat(indent_level); - let mut text = String::with_capacity(1 + indent.len()); + let indent_len = indent.len(); + let mut text = String::with_capacity(1 + indent_len); text.push('\n'); text.push_str(&indent); let text = text.repeat(count); @@ -1653,7 +1654,10 @@ fn open(cx: &mut Context, open: Open) { offs + linend_index + 1 }; for i in 0..count { - ranges.push(Range::new(pos + i, pos + i)); + // pos -> beginning of reference line, + // + (i * (1+indent_len)) -> beginning of i'th line from pos + // + indent_len -> -> indent for i'th line + ranges.push(Range::point(pos + (i * (1 + indent_len)) + indent_len)); } offs += text.chars().count(); -- cgit v1.2.3-70-g09d2