aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/match_brackets.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/match_brackets.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/match_brackets.rs')
-rw-r--r--helix-core/src/match_brackets.rs7
1 files changed, 4 insertions, 3 deletions
diff --git a/helix-core/src/match_brackets.rs b/helix-core/src/match_brackets.rs
index 2aa87620..f3d9e845 100644
--- a/helix-core/src/match_brackets.rs
+++ b/helix-core/src/match_brackets.rs
@@ -24,12 +24,13 @@ pub fn find(syntax: &Syntax, doc: &Rope, pos: usize) -> Option<usize> {
return None;
}
- let start_byte = node.start_byte();
let len = doc.len_bytes();
- if start_byte >= len {
+ let start_byte = node.start_byte();
+ let end_byte = node.end_byte() - 1; // it's end exclusive
+ if start_byte >= len || end_byte >= len {
return None;
}
- let end_byte = node.end_byte() - 1; // it's end exclusive
+
let start_char = doc.byte_to_char(start_byte);
let end_char = doc.byte_to_char(end_byte);