mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-20 02:08:47 +00:00
cleanup suggest settings (#238709)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# Terminal Suggestions
|
||||
|
||||
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled. To enable the completions from this extension, set `terminal.integrated.suggest.enabled` and `terminal.integrated.suggest.enableExtensionCompletions` to `true`.
|
||||
**Notice:** This extension is bundled with Visual Studio Code. It can be disabled but not uninstalled. To enable the completions from this extension, set `terminal.integrated.suggest.enabled` to `true`.
|
||||
|
||||
## Features
|
||||
|
||||
|
||||
@@ -65,20 +65,15 @@ class TerminalSuggestContribution extends DisposableStore implements ITerminalCo
|
||||
}));
|
||||
this._terminalSuggestWidgetVisibleContextKey = TerminalContextKeys.suggestWidgetVisible.bindTo(this._contextKeyService);
|
||||
this.add(this._configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration(TerminalSuggestSettingId.EnableExtensionCompletions) || e.affectsConfiguration(TerminalSuggestSettingId.Enabled)) {
|
||||
const extensionCompletionsEnabled = this._configurationService.getValue<ITerminalSuggestConfiguration>(terminalSuggestConfigSection).enableExtensionCompletions;
|
||||
if (e.affectsConfiguration(TerminalSuggestSettingId.Enabled)) {
|
||||
const completionsEnabled = this._configurationService.getValue<ITerminalSuggestConfiguration>(terminalSuggestConfigSection).enabled;
|
||||
if (!extensionCompletionsEnabled || !completionsEnabled) {
|
||||
this._addon.clear();
|
||||
}
|
||||
if (!completionsEnabled) {
|
||||
this._addon.clear();
|
||||
this._pwshAddon.clear();
|
||||
}
|
||||
const xtermRaw = this._ctx.instance.xterm?.raw;
|
||||
if (!!xtermRaw && extensionCompletionsEnabled || completionsEnabled) {
|
||||
if (xtermRaw) {
|
||||
this._loadAddons(xtermRaw);
|
||||
}
|
||||
if (!!xtermRaw && completionsEnabled) {
|
||||
this._loadAddons(xtermRaw);
|
||||
}
|
||||
}
|
||||
}));
|
||||
|
||||
@@ -14,7 +14,7 @@ import { IFileService } from '../../../../../platform/files/common/files.js';
|
||||
import { createDecorator } from '../../../../../platform/instantiation/common/instantiation.js';
|
||||
import { TerminalShellType } from '../../../../../platform/terminal/common/terminal.js';
|
||||
import { ISimpleCompletion } from '../../../../services/suggest/browser/simpleCompletionItem.js';
|
||||
import { ITerminalSuggestConfiguration, terminalSuggestConfigSection, TerminalSuggestSettingId } from '../common/terminalSuggestConfiguration.js';
|
||||
import { TerminalSuggestSettingId } from '../common/terminalSuggestConfiguration.js';
|
||||
|
||||
export const ITerminalCompletionService = createDecorator<ITerminalCompletionService>('terminalCompletionService');
|
||||
|
||||
@@ -131,7 +131,6 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
|
||||
return undefined;
|
||||
}
|
||||
|
||||
const extensionCompletionsEnabled = this._configurationService.getValue<ITerminalSuggestConfiguration>(terminalSuggestConfigSection).enableExtensionCompletions;
|
||||
let providers;
|
||||
if (triggerCharacter) {
|
||||
const providersToRequest: ITerminalCompletionProvider[] = [];
|
||||
@@ -151,7 +150,7 @@ export class TerminalCompletionService extends Disposable implements ITerminalCo
|
||||
providers = [...this._providers.values()].flatMap(providerMap => [...providerMap.values()]);
|
||||
}
|
||||
|
||||
if (!extensionCompletionsEnabled || skipExtensionCompletions) {
|
||||
if (skipExtensionCompletions) {
|
||||
providers = providers.filter(p => p.isBuiltin);
|
||||
return this._collectCompletions(providers, shellType, promptValue, cursorPosition, token);
|
||||
}
|
||||
|
||||
@@ -156,8 +156,7 @@ export class SuggestAddon extends Disposable implements ITerminalAddon, ISuggest
|
||||
doNotRequestExtensionCompletions = true;
|
||||
}
|
||||
|
||||
const enableExtensionCompletions = this._configurationService.getValue<ITerminalSuggestConfiguration>(terminalSuggestConfigSection).enableExtensionCompletions;
|
||||
if (enableExtensionCompletions && !doNotRequestExtensionCompletions) {
|
||||
if (!doNotRequestExtensionCompletions) {
|
||||
await this._extensionService.activateByEvent('onTerminalCompletionsRequested');
|
||||
}
|
||||
this._currentPromptInputState = {
|
||||
|
||||
@@ -14,7 +14,6 @@ export const enum TerminalSuggestSettingId {
|
||||
SuggestOnTriggerCharacters = 'terminal.integrated.suggest.suggestOnTriggerCharacters',
|
||||
RunOnEnter = 'terminal.integrated.suggest.runOnEnter',
|
||||
BuiltinCompletions = 'terminal.integrated.suggest.builtinCompletions',
|
||||
EnableExtensionCompletions = 'terminal.integrated.suggest.enableExtensionCompletions',
|
||||
WindowsExecutableExtensions = 'terminal.integrated.suggest.windowsExecutableExtensions',
|
||||
Providers = 'terminal.integrated.suggest.providers',
|
||||
ShowStatusBar = 'terminal.integrated.suggest.showStatusBar',
|
||||
@@ -54,20 +53,19 @@ export interface ITerminalSuggestConfiguration {
|
||||
'terminal-suggest': boolean;
|
||||
'pwsh-shell-integration': boolean;
|
||||
};
|
||||
enableExtensionCompletions: boolean;
|
||||
}
|
||||
|
||||
export const terminalSuggestConfiguration: IStringDictionary<IConfigurationPropertySchema> = {
|
||||
[TerminalSuggestSettingId.Enabled]: {
|
||||
restricted: true,
|
||||
markdownDescription: localize('suggest.enabled', "Enables experimental terminal Intellisense suggestions for supported shells ({0}) when {1} is set to {2}.\n\nIf shell integration is installed manually, {3} needs to be set to {4} before calling the shell integration script. \n\nFor extension provided completions, {5} will also need to be set.", 'PowerShell v7+, zsh, bash, fish', `\`#${TerminalSettingId.ShellIntegrationEnabled}#\``, '`true`', '`VSCODE_SUGGEST`', '`1`', `\`#${TerminalSuggestSettingId.EnableExtensionCompletions}#\``),
|
||||
markdownDescription: localize('suggest.enabled', "Enables experimental terminal Intellisense suggestions for supported shells ({0}) when {1} is set to {2}.\n\nIf shell integration is installed manually, {3} needs to be set to {4} before calling the shell integration script.", 'PowerShell v7+, zsh, bash, fish', `\`#${TerminalSettingId.ShellIntegrationEnabled}#\``, '`true`', '`VSCODE_SUGGEST`', '`1`'),
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
tags: ['experimental'],
|
||||
},
|
||||
[TerminalSuggestSettingId.Providers]: {
|
||||
restricted: true,
|
||||
markdownDescription: localize('suggest.providers', "Controls which providers are enabled for terminal suggestions. Also be aware of the {0}-setting which controls if extensions are able to provide suggestions.", `\`#${TerminalSuggestSettingId.EnableExtensionCompletions}#\``),
|
||||
markdownDescription: localize('suggest.providers', "Controls which providers are enabled for terminal suggestions."),
|
||||
type: 'object',
|
||||
properties: {},
|
||||
default: {
|
||||
@@ -120,16 +118,9 @@ export const terminalSuggestConfiguration: IStringDictionary<IConfigurationPrope
|
||||
pwshGit: true,
|
||||
}
|
||||
},
|
||||
[TerminalSuggestSettingId.EnableExtensionCompletions]: {
|
||||
restricted: true,
|
||||
markdownDescription: localize('suggest.enableExtensionCompletions', "Controls whether extension completions are enabled. Also be aware of the {0}-setting which controls which providers are enabled.", `\`#${TerminalSuggestSettingId.Providers}#\``),
|
||||
type: 'boolean',
|
||||
default: false,
|
||||
tags: ['experimental'],
|
||||
},
|
||||
[TerminalSuggestSettingId.WindowsExecutableExtensions]: {
|
||||
restricted: true,
|
||||
markdownDescription: localize("terminalWindowsExecutableSuggestionSetting", "A set of windows command executable extensions that will be included as suggestions in the terminal. For example, `exe` and `bat`.\n\nMany executables are included by default, listed below:\n\n{0}.\n\nTo exclude an extension, set it to `false`\n\n. To include one not in the list, add it and set it to `true`.",
|
||||
markdownDescription: localize("terminalWindowsExecutableSuggestionSetting", "A set of windows command executable extensions that will be included as suggestions in the terminal.\n\nMany executables are included by default, listed below:\n\n{0}.\n\nTo exclude an extension, set it to `false`\n\n. To include one not in the list, add it and set it to `true`.",
|
||||
windowsDefaultExecutableExtensions.sort().map(extension => `- ${extension}`).join('\n'),
|
||||
),
|
||||
type: 'object',
|
||||
|
||||
@@ -109,7 +109,6 @@ suite('Terminal Contrib Suggest Recordings', () => {
|
||||
'terminal-suggest': true,
|
||||
'pwsh-shell-integration': true,
|
||||
},
|
||||
enableExtensionCompletions: false
|
||||
} satisfies ITerminalSuggestConfiguration
|
||||
}
|
||||
};
|
||||
@@ -126,7 +125,7 @@ suite('Terminal Contrib Suggest Recordings', () => {
|
||||
instantiationService.stub(ITerminalCompletionService, store.add(completionService));
|
||||
const shellIntegrationAddon = store.add(new ShellIntegrationAddon('', true, undefined, new NullLogService));
|
||||
pwshCompletionProvider = store.add(instantiationService.createInstance(PwshCompletionProviderAddon, new Set(parseCompletionsFromShell(testRawPwshCompletions, -1, -1)), shellIntegrationAddon.capabilities));
|
||||
store.add(completionService.registerTerminalCompletionProvider('builtin-pwsh', 'pwsh', pwshCompletionProvider));
|
||||
store.add(completionService.registerTerminalCompletionProvider('builtin-pwsh', PwshCompletionProviderAddon.ID, pwshCompletionProvider));
|
||||
const TerminalCtor = (await importAMDNodeModule<typeof import('@xterm/xterm')>('@xterm/xterm', 'lib/xterm.js')).Terminal;
|
||||
xterm = store.add(new TerminalCtor({ allowProposedApi: true }));
|
||||
capabilities = shellIntegrationAddon.capabilities;
|
||||
|
||||
Reference in New Issue
Block a user