Skip to content

Commit

Permalink
fix: Tab in console input triggers autocomplete instead of indent (#1591
Browse files Browse the repository at this point in the history
)

In the console, pressing the `Tab` key previously brought up the
autocomplete prompt. Now it will insert a tab's worth of spaces instead.

Can still trigger autocomplete by using `Ctrl+Space`
  • Loading branch information
mattrunyon committed Oct 24, 2023
1 parent a4013c0 commit fbe1e70
Showing 1 changed file with 11 additions and 25 deletions.
36 changes: 11 additions & 25 deletions packages/console/src/ConsoleInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,6 @@ export class ConsoleInput extends PureComponent<
top: TOP_PADDING,
bottom: BOTTOM_PADDING,
},
tabCompletion: 'on',
value: '',
wordWrap: 'on',
} as const;
Expand Down Expand Up @@ -255,30 +254,17 @@ export class ConsoleInput extends PureComponent<
}

if (!keyEvent.altKey && !keyEvent.shiftKey && !keyEvent.metaKey) {
if (keyEvent.keyCode === monaco.KeyCode.Enter) {
if (!this.isSuggestionMenuPopulated()) {
keyEvent.stopPropagation();
keyEvent.preventDefault();

const command = this.commandEditor?.getValue().trim();
if (command !== undefined) {
this.processCommand(command);
this.commandEditor?.setValue('');
}
}
} else if (keyEvent.keyCode === monaco.KeyCode.Tab) {
if (!this.isSuggestionMenuActive()) {
keyEvent.stopPropagation();
keyEvent.preventDefault();

this.commandEditor?.trigger(
'Tab key trigger suggestions',
'editor.action.triggerSuggest',
{}
);
} else if (!this.isSuggestionMenuPopulated()) {
keyEvent.stopPropagation();
keyEvent.preventDefault();
if (
keyEvent.keyCode === monaco.KeyCode.Enter &&
!this.isSuggestionMenuPopulated()
) {
keyEvent.stopPropagation();
keyEvent.preventDefault();

const command = this.commandEditor?.getValue().trim();
if (command !== undefined) {
this.processCommand(command);
this.commandEditor?.setValue('');
}
}
}
Expand Down

0 comments on commit fbe1e70

Please sign in to comment.