summaryrefslogtreecommitdiff
path: root/helix-term/src
diff options
context:
space:
mode:
authorGabriel Dinner-David2022-12-31 14:23:55 +0000
committerGitHub2022-12-31 14:23:55 +0000
commit1b1755240db1ca01cbe1371a5b4ac58b68615382 (patch)
tree2dffc451c66cf9733a75c6e07b37f7315a0c916d /helix-term/src
parentc9ed42cdec95b67b0d0ed15218daff37358ca86f (diff)
fix(commands): extend_line to proper line when count and current line selected (#5288)
Diffstat (limited to 'helix-term/src')
-rw-r--r--helix-term/src/commands.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/helix-term/src/commands.rs b/helix-term/src/commands.rs
index 7ee1d77c..09c2e5df 100644
--- a/helix-term/src/commands.rs
+++ b/helix-term/src/commands.rs
@@ -2053,16 +2053,10 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
let selection = doc.selection(view.id).clone().transform(|range| {
let (start_line, end_line) = range.line_range(text.slice(..));
- let start = text.line_to_char(match extend {
- Extend::Above => start_line.saturating_sub(count - 1),
- Extend::Below => start_line,
- });
+ let start = text.line_to_char(start_line);
let end = text.line_to_char(
- match extend {
- Extend::Above => end_line + 1, // the start of next line
- Extend::Below => end_line + count,
- }
- .min(text.len_lines()),
+ (end_line + 1) // newline of end_line
+ .min(text.len_lines()),
);
// extend to previous/next line if current line is selected
@@ -2076,8 +2070,11 @@ fn extend_line_impl(cx: &mut Context, extend: Extend) {
}
} else {
match extend {
- Extend::Above => (end, start),
- Extend::Below => (start, end),
+ Extend::Above => (end, text.line_to_char(start_line.saturating_sub(count - 1))),
+ Extend::Below => (
+ start,
+ text.line_to_char((end_line + count).min(text.len_lines())),
+ ),
}
};