Skip to content

Commit f15aa39

Browse files
authored
add a new (unbound) command to focus and accept the first suggestion (microsoft#174856)
microsoft#173387
1 parent 9c0d571 commit f15aa39

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/vs/editor/contrib/suggest/browser/suggestController.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -907,7 +907,7 @@ registerEditorCommand(new SuggestCommand({
907907

908908
registerEditorCommand(new SuggestCommand({
909909
id: 'focusSuggestion',
910-
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.HasFocusedSuggestion.negate(), ContextKeyExpr.equals('config.editor.suggest.selectQuickSuggestions', false)),
910+
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.HasFocusedSuggestion.negate()),
911911
handler: x => x.focusSuggestion(),
912912
kbOpts: {
913913
weight: weight,
@@ -918,6 +918,15 @@ registerEditorCommand(new SuggestCommand({
918918
},
919919
}));
920920

921+
registerEditorCommand(new SuggestCommand({
922+
id: 'focusAndAcceptSuggestion',
923+
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.HasFocusedSuggestion.negate()),
924+
handler: c => {
925+
c.focusSuggestion();
926+
c.acceptSelectedSuggestion(true, false);
927+
}
928+
}));
929+
921930
registerEditorCommand(new SuggestCommand({
922931
id: 'toggleSuggestionDetails',
923932
precondition: ContextKeyExpr.and(SuggestContext.Visible, SuggestContext.HasFocusedSuggestion),

src/vs/editor/contrib/suggest/test/browser/suggestModel.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1087,8 +1087,6 @@ suite('SuggestModel - TriggerAndCancelOracle', function () {
10871087

10881088
return withOracle(async function (model, editor) {
10891089

1090-
// editor.updateOptions({ suggest: { selectQuickSuggestions: 'whenQuickSuggestion' } });
1091-
10921090
await assertEvent(model.onDidSuggest, () => {
10931091
editor.setValue('foo');
10941092
editor.setSelection(new Selection(1, 4, 1, 4));

0 commit comments

Comments
 (0)