diff --git a/Projects/Src/IDE.HelperFunc.pas b/Projects/Src/IDE.HelperFunc.pas index dffa89be7..96a9a855a 100644 --- a/Projects/Src/IDE.HelperFunc.pas +++ b/Projects/Src/IDE.HelperFunc.pas @@ -76,8 +76,6 @@ function GetSourcePath(const AFilename: String): String; function ReadScriptLines(const ALines: TStringList; const ReadFromFile: Boolean; const ReadFromFileFilename: String; const NotReadFromFileMemo: TScintEdit): Integer; function CreateBitmapInfo(const Width, Height, BitCount: Integer): TBitmapInfo; -function GetWordOccurrenceFindOptions: TScintFindOptions; -function GetSelTextOccurrenceFindOptions: TScintFindOptions; function GetPreferredMemoFont: String; function DoubleAmp(const S: String): String; @@ -848,16 +846,6 @@ function CreateBitmapInfo(const Width, Height, BitCount: Integer): TBitmapInfo; Result.bmiHeader.biCompression := BI_RGB; end; -function GetWordOccurrenceFindOptions: TScintFindOptions; -begin - Result := [sfoMatchCase, sfoWholeWord]; -end; - -function GetSelTextOccurrenceFindOptions: TScintFindOptions; -begin - Result := []; -end; - var PreferredMemoFont: String; diff --git a/Projects/Src/IDE.MainForm.pas b/Projects/Src/IDE.MainForm.pas index a5272d661..9817d36ce 100644 --- a/Projects/Src/IDE.MainForm.pas +++ b/Projects/Src/IDE.MainForm.pas @@ -2995,26 +2995,20 @@ procedure TMainForm.ESelectAllClick(Sender: TObject); procedure TMainForm.ESelectAllOccurrencesClick(Sender: TObject); begin { Might be called even if ESelectAllOccurrences.Enabled would be False in EMenuClick } - var Options := GetSelTextOccurrenceFindOptions; if FActiveMemo.SelEmpty then begin + { If the selection is empty then SelectAllOccurrences will actually just select + the word at caret which is not what we want, so preselect this word ourselves } var Range := FActiveMemo.WordAtCursorRange; - if Range.StartPos <> Range.EndPos then begin + if Range.StartPos <> Range.EndPos then FActiveMemo.SetSingleSelection(Range.EndPos, Range.StartPos); - Options := GetWordOccurrenceFindOptions; - end; end; - FActiveMemo.SelectAllOccurrences(Options); + FActiveMemo.SelectAllOccurrences([sfoMatchCase]); end; procedure TMainForm.ESelectNextOccurrenceClick(Sender: TObject); begin { Might be called even if ESelectNextOccurrence.Enabled would be False in EMenuClick } - - { Currently this always uses GetWordOccurrenceFindOptions but ideally it would - know whether this is the 'first' SelectNext or not. Then, if first it would - do what SelectAll does to choose a FindOptions. And if next it would reuse - that. This is what VSCode does. } - FActiveMemo.SelectNextOccurrence(GetWordOccurrenceFindOptions); + FActiveMemo.SelectNextOccurrence([sfoMatchCase]); end; procedure TMainForm.EToggleLinesCommentClick(Sender: TObject); @@ -4027,7 +4021,7 @@ procedure TMainForm.UpdateOccurrenceIndicators(const AMemo: TIDEScintEdit); if (Word.StartPos <> Word.EndPos) and MainSelection.Within(Word) then begin var TextToIndicate := AMemo.GetRawTextRange(Word.StartPos, Word.EndPos); AMemo.GetSelections(Selections); { Gets any additional selections as well } - FindTextAndAddRanges(AMemo, TextToIndicate, GetWordOccurrenceFindOptions, Selections, IndicatorRanges); + FindTextAndAddRanges(AMemo, TextToIndicate, [sfoMatchCase, sfoWholeWord], Selections, IndicatorRanges); end; end; AMemo.UpdateIndicators(IndicatorRanges, minWordAtCursorOccurrence); @@ -4037,7 +4031,7 @@ procedure TMainForm.UpdateOccurrenceIndicators(const AMemo: TIDEScintEdit); var TextToIndicate := AMemo.RawMainSelText; if Selections.Count = 0 then { If 0 then we didn't already call GetSelections above} AMemo.GetSelections(Selections); - FindTextAndAddRanges(AMemo, TextToIndicate, GetSelTextOccurrenceFindOptions, Selections, IndicatorRanges); + FindTextAndAddRanges(AMemo, TextToIndicate, [], Selections, IndicatorRanges); end; AMemo.UpdateIndicators(IndicatorRanges, minSelTextOccurrence); finally