Skip to content

Commit e9b254e

Browse files
authored
use chord instead of label (microsoft#218107)
1 parent 682fa68 commit e9b254e

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/vs/workbench/contrib/interactive/browser/replInputHintContentWidget.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import * as dom from 'vs/base/browser/dom';
77
import { status } from 'vs/base/browser/ui/aria/aria';
88
import { KeybindingLabel } from 'vs/base/browser/ui/keybindingLabel/keybindingLabel';
99
import { Event } from 'vs/base/common/event';
10+
import { ResolvedKeybinding } from 'vs/base/common/keybindings';
1011
import { Disposable } from 'vs/base/common/lifecycle';
1112
import { OS } from 'vs/base/common/platform';
1213
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget, IContentWidgetPosition } from 'vs/editor/browser/editorBrowser';
@@ -121,25 +122,29 @@ export class ReplInputHintContentWidget extends Disposable implements IContentWi
121122
private getKeybinding() {
122123
const keybindings = this.keybindingService.lookupKeybindings('interactive.execute');
123124
const shiftEnterConfig = this.configurationService.getValue(InteractiveWindowSetting.executeWithShiftEnter);
125+
const hasChord = (chord: string, kb: ResolvedKeybinding) => {
126+
const chords = kb.getDispatchChords();
127+
return chords.length === 1 && chords[0] === chord;
128+
};
124129

125130
if (shiftEnterConfig) {
126-
const keybinding = keybindings.find(kb => kb.getLabel() === 'Shift+Enter');
131+
const keybinding = keybindings.find(kb => hasChord('shift+Enter', kb));
127132
if (keybinding) {
128133
return keybinding;
129134
}
130135
} else {
131-
let keybinding = keybindings.find(kb => kb.getLabel() === 'Enter');
136+
let keybinding = keybindings.find(kb => hasChord('Enter', kb));
132137
if (keybinding) {
133138
return keybinding;
134139
}
135140
keybinding = this.keybindingService.lookupKeybindings('python.execInREPLEnter')
136-
.find(kb => kb.getLabel() === 'Enter');
141+
.find(kb => hasChord('Enter', kb));
137142
if (keybinding) {
138143
return keybinding;
139144
}
140145
}
141146

142-
return undefined;
147+
return keybindings?.[0];
143148
}
144149

145150
override dispose(): void {

0 commit comments

Comments
 (0)