From d45911767d49086b3c6b82e58537843b88e9e317 Mon Sep 17 00:00:00 2001 From: Timothy Warren Date: Wed, 11 Sep 2019 10:37:18 -0400 Subject: [PATCH] Fix keyword highlighting off-by-one errors, to fix keyword highlighting --- src/editor.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/editor.rs b/src/editor.rs index 53c4a5d..c63028b 100644 --- a/src/editor.rs +++ b/src/editor.rs @@ -575,7 +575,7 @@ impl Editor { let search_range = get_slice_range(i, keyword.len(), render_len); - let next_char_offset = i + keyword.len() + 1; + let next_char_offset = i + keyword.len(); let is_end_of_line = next_char_offset >= render_len; let next_char = if is_end_of_line { '\0' @@ -585,7 +585,7 @@ impl Editor { if &row.render[search_range.clone()] == keyword && is_separator(next_char) { highlight_range(&mut row.highlight, search_range, Highlight::Keyword1); - i += keyword.len(); + i += keyword.len() - 1; } } @@ -596,7 +596,7 @@ impl Editor { let search_range = get_slice_range(i, keyword.len(), render_len); - let next_char_offset = i + keyword.len() + 1; + let next_char_offset = i + keyword.len(); let is_end_of_line = next_char_offset >= render_len; let next_char = if is_end_of_line { '\0' @@ -606,7 +606,7 @@ impl Editor { if &row.render[search_range.clone()] == keyword && is_separator(next_char) { highlight_range(&mut row.highlight, search_range, Highlight::Keyword2); - i += keyword.len(); + i += keyword.len() - 1; } } }