From b929933b8261889b2b0275b5809c763d0c0f32b2 Mon Sep 17 00:00:00 2001 From: pommicket Date: Wed, 14 Jun 2023 11:28:24 +0100 Subject: fix problem where unmatched bracket highlights eof --- buffer.c | 8 ++++++-- 1 file 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; } -- cgit v1.2.3