Skip to content

Commit

Permalink
Merge pull request #80273 from microsoft/rebornix/fix-kb-find-win32
Browse files Browse the repository at this point in the history
Correct kb validation for windows ctrl.
  • Loading branch information
rebornix authored Sep 3, 2019
2 parents 5ab84ce + 223d9f9 commit 3db7e09
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/vs/editor/contrib/find/findWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ let FIND_ALL_CONTROLS_WIDTH = 17/** Find Input margin-left */ + (MAX_MATCHES_COU
const FIND_INPUT_AREA_HEIGHT = 33; // The height of Find Widget when Replace Input is not visible.
const ctrlEnterReplaceAllWarningPromptedKey = 'ctrlEnterReplaceAll.windows.donotask';

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

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

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

if (start && end) {
if (start !== null && end !== null) {
const value = content.substr(0, start) + '\n' + content.substr(end);
this._replaceInput.inputBox.value = value;
inputElement.setSelectionRange(start + 1, start + 1);
Expand Down

0 comments on commit 3db7e09

Please sign in to comment.