From 6d95fc4eb211d79fb876b2fbdd0bbabcd97b852e Mon Sep 17 00:00:00 2001 From: haven1433 Date: Sat, 3 Dec 2022 21:11:55 -0600 Subject: [PATCH] fix "" constants and ~n constants --- .../ViewModels/TextEditorViewModel.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/HexManiac.Core/ViewModels/TextEditorViewModel.cs b/src/HexManiac.Core/ViewModels/TextEditorViewModel.cs index b7676cfc..f5153737 100644 --- a/src/HexManiac.Core/ViewModels/TextEditorViewModel.cs +++ b/src/HexManiac.Core/ViewModels/TextEditorViewModel.cs @@ -167,9 +167,21 @@ namespace HavenSoft.HexManiac.Core.ViewModels { public IEnumerable<(int start, int length)> GetPossibleKeywordStartPoints() { for (int i = 0; i < content.Length - 1; i++) { if (i > 0 && char.IsLetterOrDigit(content[i - 1])) continue; // not valid keyword start + if (content[i] == '"') { + // look for matching + var closeIndex = i; + for (int j = i + 1; j < content.Length; j++) { + if (content[j] != '"') continue; + closeIndex = j; + break; + } + if (closeIndex == i) break; + yield return (i, closeIndex - i + 1); + i = closeIndex + 1; + } if (!char.IsLetter(content[i])) continue; - int length = 1; - while (i + length < content.Length && (char.IsLetterOrDigit(content[i + length]) || content[i + length] == '.')) length++; + int length = 1; + while (i + length < content.Length && (char.IsLetterOrDigit(content[i + length]) || content[i + length].IsAny(".'-~".ToCharArray()))) length++; yield return (i, length); i += length; }