Skip to content

Commit 3db7e09

Browse files
authored
Merge pull request microsoft#80273 from microsoft/rebornix/fix-kb-find-win32
Correct kb validation for windows ctrl.
2 parents 5ab84ce + 223d9f9 commit 3db7e09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/vs/editor/contrib/find/findWidget.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COU
6767
const FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible.
6868
const ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask';
6969

70+
const ctrlKeyMod = (platform.isMacintosh ? KeyMod.WinCtrl : KeyMod.CtrlCmd);
7071
export class FindWidgetViewZone implements IViewZone {
7172
public readonly afterLineNumber: number;
7273
public heightInPx: number;
@@ -775,7 +776,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
775776
}
776777

777778
private _onFindInputKeyDown(e: IKeyboardEvent): void {
778-
if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) {
779+
if (e.equals(ctrlKeyMod | KeyCode.Enter)) {
779780
const inputElement = this._findInput.inputBox.inputElement;
780781
const start = inputElement.selectionStart;
781782
const end = inputElement.selectionEnd;
@@ -817,7 +818,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
817818
}
818819

819820
private _onReplaceInputKeyDown(e: IKeyboardEvent): void {
820-
if (e.equals(KeyMod.WinCtrl | KeyCode.Enter)) {
821+
if (e.equals(ctrlKeyMod | KeyCode.Enter)) {
821822
if (platform.isWindows && platform.isNative && !this._ctrlEnterReplaceAllWarningPrompted) {
822823
// this is the first time when users press Ctrl + Enter to replace all
823824
this._notificationService.info(
@@ -835,7 +836,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
835836
const end = inputElement.selectionEnd;
836837
const content = inputElement.value;
837838

838-
if (start && end) {
839+
if (start !== null && end !== null) {
839840
const value = content.substr(0, start) + '\n' + content.substr(end);
840841
this._replaceInput.inputBox.value = value;
841842
inputElement.setSelectionRange(start + 1, start + 1);

0 commit comments

Comments
 (0)