diff --git a/Projects/Src/CompForm.pas b/Projects/Src/CompForm.pas index e30a3b612..b28ec9daf 100644 --- a/Projects/Src/CompForm.pas +++ b/Projects/Src/CompForm.pas @@ -1065,27 +1065,13 @@ procedure TCompileForm.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin var AShortCut := ShortCut(Key, Shift); - if AShortCut = VK_ESCAPE then begin - if BStopCompile.Enabled then - BStopCompileClick(Self) - else begin - { The built in Esc (SCI_CANCEL) simply drops all additional selections - and does not empty the main selection, It doesn't matter if Esc is - pressed once or twice. Implement our own behaviour, same as VSCode. - Also see https://github.com/microsoft/vscode/issues/118835. } - if FActiveMemo.SelectionCount > 1 then - FActiveMemo.RemoveAdditionalSelections - else if not FActiveMemo.SelEmpty then - FActiveMemo.SetEmptySelection; - FActiveMemo.ScrollCaretIntoView; - end; - end else if AShortCut = FBackNavButtonShortCut then begin - if BackNavButton.Enabled then - BackNavButtonClick(Self); - end else if AShortCut = FForwardNavButtonShortCut then begin - if ForwardNavButton.Enabled then - ForwardNavButtonClick(Self); - end else if (Key = VK_F6) and not(ssAlt in Shift) then begin + if (AShortCut = VK_ESCAPE) and BStopCompile.Enabled then + BStopCompileClick(Self) + else if (AShortCut = FBackNavButtonShortCut) and BackNavButton.Enabled then + BackNavButtonClick(Self) + else if (AShortCut = FForwardNavButtonShortCut) and ForwardNavButton.Enabled then + ForwardNavButtonClick(Self) + else if (Key = VK_F6) and not(ssAlt in Shift) then begin { Toggle focus between the active memo and the active bottom pane } Key := 0; if ActiveControl <> FActiveMemo then @@ -1107,6 +1093,18 @@ procedure TCompileForm.FormKeyDown(Sender: TObject; var Key: Word; ccSelectAllOccurrences: if ESelectAllOccurrences.Enabled then ESelectAllOccurrencesClick(Self); + ccSimplifySelection: + begin + { The built in Esc (SCI_CANCEL) simply drops all additional selections + and does not empty the main selection, It doesn't matter if Esc is + pressed once or twice. Implement our own behaviour, same as VSCode. + Also see https://github.com/microsoft/vscode/issues/118835. } + if FActiveMemo.SelectionCount > 1 then + FActiveMemo.RemoveAdditionalSelections + else if not FActiveMemo.SelEmpty then + FActiveMemo.SetEmptySelection; + FActiveMemo.ScrollCaretIntoView; + end; else if ComplexCommand <> ccNone then raise Exception.Create('Unknown ComplexCommand'); end; diff --git a/Projects/Src/CompScintEdit.pas b/Projects/Src/CompScintEdit.pas index f9f011a81..0b6c5075f 100644 --- a/Projects/Src/CompScintEdit.pas +++ b/Projects/Src/CompScintEdit.pas @@ -64,7 +64,7 @@ interface { Commands which require more than 1 parameterless SCI_XXXXX and need help from the container } TCompScintComplexCommand = (ccNone, ccSelectNextOccurrence, - ccSelectAllOccurrences); + ccSelectAllOccurrences, ccSimplifySelection); TCompScintEdit = class(TScintEdit) private @@ -400,6 +400,8 @@ procedure TCompScintEdit.UpdateComplexCommands; AddComplexCommand(ShortCut(VK_OEM_PERIOD, [ssShift, ssAlt]), ccSelectNextOccurrence); AddComplexCommand(ShortCut(VK_OEM_1, [ssShift, ssAlt]), ccSelectAllOccurrences); end; + + AddComplexCommand(ShortCut(VK_ESCAPE, []), ccSimplifySelection); end; procedure TCompScintEdit.SetUseFolding(const Value: Boolean);