summaryrefslogtreecommitdiff
path: root/helix-term/src/commands.rs
diff options
context:
space:
mode:
authorGokul Soumya2021-06-18 08:50:25 +0000
committerBlaž Hrastnik2021-06-18 12:30:58 +0000
commitb1cb98283dacf98fb15e5fbcdb12d0be4161190b (patch)
treea9a2c567047739d4086a05a8c664c6477dd385aa /helix-term/src/commands.rs
parenta3cb79ebaaaa7682c7c7b007ed928b24f80cf3c2 (diff)
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
Diffstat (limited to 'helix-term/src/commands.rs')
-rw-r--r--helix-term/src/commands.rs8
1 files changed, 6 insertions, 2 deletions
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();