From e2cc6f3cd430a8cf7eb47816a2d75a538e0d3c5c Mon Sep 17 00:00:00 2001 From: psyGamer Date: Sun, 17 Nov 2024 19:21:28 +0100 Subject: [PATCH] fix(Studio): Find dialog finding wrong result locations --- Studio/CelesteStudio/Dialog/FindDialog.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Studio/CelesteStudio/Dialog/FindDialog.cs b/Studio/CelesteStudio/Dialog/FindDialog.cs index 3cf3faf8..2714b6d8 100644 --- a/Studio/CelesteStudio/Dialog/FindDialog.cs +++ b/Studio/CelesteStudio/Dialog/FindDialog.cs @@ -120,23 +120,23 @@ private void UpdateMatches() { var compare = (matchCase.Checked ?? false) ? StringComparison.InvariantCulture : StringComparison.InvariantCultureIgnoreCase; matches.Clear(); - var search = searchQuery.Text; + string search = searchQuery.Text; if (search.Length == 0) { return; } for (int row = 0; row < editor.Document.Lines.Count; row++) { - var line = editor.Document.Lines[row]; + string line = editor.Document.Lines[row]; int col = 0; while (true) { - int idx = line.IndexOf(searchQuery.Text, col, compare); - if (idx < 0) { + col = line.IndexOf(searchQuery.Text, col, compare); + if (col < 0) { break; } - matches.Add(new CaretPosition(row, col + idx)); - col = idx + searchQuery.Text.Length; + matches.Add(new CaretPosition(row, col)); + col += searchQuery.Text.Length; } }