summaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorpommicket <pommicket@gmail.com>2023-06-14 11:28:24 +0100
committerpommicket <pommicket@gmail.com>2023-06-14 11:28:24 +0100
commitb929933b8261889b2b0275b5809c763d0c0f32b2 (patch)
tree39d1d1144c64c646192a5860bf3e50f60367daaa /buffer.c
parent8a6fa4a33a8664d5642853418821f88c7c2930df (diff)
fix problem where unmatched bracket highlights eof
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/buffer.c b/buffer.c
index 09b0efd..4ec789b 100644
--- a/buffer.c
+++ b/buffer.c
@@ -2872,13 +2872,17 @@ bool buffer_pos_move_to_matching_bracket(TextBuffer *buffer, BufferPos *pos) {
if (bracket_char && matching_char) {
int direction = syntax_is_opening_bracket(language, bracket_char) ? +1 : -1;
int depth = 1;
+ bool found_bracket = false;
while (buffer_pos_move_right(buffer, pos, direction)) {
char32_t c = buffer_char_at_pos(buffer, *pos);
if (c == bracket_char) depth += 1;
else if (c == matching_char) depth -= 1;
- if (depth == 0) break;
+ if (depth == 0) {
+ found_bracket = true;
+ break;
+ }
}
- return true;
+ return found_bracket;
} else {
return false;
}