aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/comment.rs
diff options
context:
space:
mode:
authorBlaž Hrastnik2021-07-29 09:43:20 +0000
committerGitHub2021-07-29 09:43:20 +0000
commit05d20e196f81c8b71c2aecaf46f5d443d6b6b582 (patch)
tree0642d43c12f16ac3c68c19602c64fdea8108cc97 /helix-core/src/comment.rs
parent8a2fa692f26f5bff5861151f395304837f5d93ec (diff)
parente4d41d06e3b52863d35ce3703f78cc8e0807c504 (diff)
Merge pull request #376 from cessen/great_line_ending_and_cursor_range_cleanup
The Great Line Ending & Cursor Range Cleanup
Diffstat (limited to 'helix-core/src/comment.rs')
-rw-r--r--helix-core/src/comment.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/helix-core/src/comment.rs b/helix-core/src/comment.rs
index fadd88e0..6fc1234d 100644
--- a/helix-core/src/comment.rs
+++ b/helix-core/src/comment.rs
@@ -64,8 +64,10 @@ pub fn toggle_line_comments(doc: &Rope, selection: &Selection, token: Option<&st
let mut min_next_line = 0;
for selection in selection {
- let start = text.char_to_line(selection.from()).max(min_next_line);
- let end = text.char_to_line(selection.to()) + 1;
+ let (start, end) = selection.line_range(text);
+ let start = start.max(min_next_line).min(text.len_lines());
+ let end = (end + 1).min(text.len_lines());
+
lines.extend(start..end);
min_next_line = end + 1;
}