Skip to content

Commit

Permalink
fix(Studio): Find dialog finding wrong result locations
Browse files Browse the repository at this point in the history
  • Loading branch information
psyGamer committed Nov 17, 2024
1 parent 53cfad9 commit e2cc6f3
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions Studio/CelesteStudio/Dialog/FindDialog.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down

0 comments on commit e2cc6f3

Please sign in to comment.