From 78872ce611340b8c54289762d41c4bcc83dcdc40 Mon Sep 17 00:00:00 2001 From: isidor Date: Fri, 16 Apr 2021 17:05:02 +0200 Subject: [PATCH] Smooth the flow of installing new debuggers fixes #119110 --- .../debug/browser/debugAdapterManager.ts | 22 ++++++++++++------- .../contrib/debug/browser/debugCommands.ts | 8 +++++-- .../contrib/debug/browser/debugService.ts | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts b/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts index 5c2ed83d10d0f..cb2081059a28b 100644 --- a/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts +++ b/src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts @@ -225,10 +225,11 @@ export class AdapterManager implements IAdapterManager { } const activeTextEditorControl = this.editorService.activeTextEditorControl; - let candidates: Debugger[] | undefined; + let candidates: Debugger[] = []; + let language: string | undefined; if (isCodeEditor(activeTextEditorControl)) { const model = activeTextEditorControl.getModel(); - const language = model ? model.getLanguageIdentifier().language : undefined; + language = model ? model.getLanguageIdentifier().language : undefined; const adapters = this.debuggers.filter(a => language && a.languages && a.languages.indexOf(language) >= 0); if (adapters.length === 1) { return adapters[0]; @@ -236,22 +237,27 @@ export class AdapterManager implements IAdapterManager { if (adapters.length > 1) { candidates = adapters; } - } - - if (!candidates) { + } else { await this.activateDebuggers('onDebugInitialConfigurations'); candidates = this.debuggers.filter(dbg => dbg.hasInitialConfiguration() || dbg.hasConfigurationProvider()); } candidates.sort((first, second) => first.label.localeCompare(second.label)); - const picks = candidates.map(c => ({ label: c.label, debugger: c })); - return this.quickInputService.pick<{ label: string, debugger: Debugger | undefined }>([...picks, { type: 'separator' }, { label: nls.localize('more', "More..."), debugger: undefined }], { placeHolder: nls.localize('selectDebug', "Select Environment") }) + const picks: { label: string, debugger?: Debugger, type?: string }[] = candidates.map(c => ({ label: c.label, debugger: c })); + let placeHolder = language ? nls.localize('CouldNotFindLanguage', "Can not find extension to debug '{0}'", language) : nls.localize('CouldNotFind', "Can not find extension to debug"); + if (picks.length > 0) { + placeHolder = nls.localize('selectDebug', "Select environment"); + picks.push({ type: 'separator', label: '' }); + } + + picks.push({ label: language ? nls.localize('installLanguage', "Install {0} extension...", language) : nls.localize('installExt', "Install extension...") }); + return this.quickInputService.pick<{ label: string, debugger?: Debugger }>(picks, { activeItem: picks[0], placeHolder }) .then(picked => { if (picked && picked.debugger) { return picked.debugger; } if (picked) { - this.commandService.executeCommand('debug.installAdditionalDebuggers'); + this.commandService.executeCommand('debug.installAdditionalDebuggers', language); } return undefined; }); diff --git a/src/vs/workbench/contrib/debug/browser/debugCommands.ts b/src/vs/workbench/contrib/debug/browser/debugCommands.ts index e30b535fed7fc..15d2a42dc2d14 100644 --- a/src/vs/workbench/contrib/debug/browser/debugCommands.ts +++ b/src/vs/workbench/contrib/debug/browser/debugCommands.ts @@ -552,10 +552,14 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({ weight: KeybindingWeight.WorkbenchContrib, when: undefined, primary: undefined, - handler: async (accessor) => { + handler: async (accessor, query: string) => { const viewletService = accessor.get(IViewletService); const viewlet = (await viewletService.openViewlet(EXTENSIONS_VIEWLET_ID, true))?.getViewPaneContainer() as IExtensionsViewPaneContainer; - viewlet.search('tag:debuggers @sort:installs'); + let searchFor = `tag:debuggers @sort:installs`; + if (typeof query === 'string') { + searchFor += ` ${query}`; + } + viewlet.search(searchFor); viewlet.focus(); } }); diff --git a/src/vs/workbench/contrib/debug/browser/debugService.ts b/src/vs/workbench/contrib/debug/browser/debugService.ts index 738c1057981da..fc116d861a76c 100644 --- a/src/vs/workbench/contrib/debug/browser/debugService.ts +++ b/src/vs/workbench/contrib/debug/browser/debugService.ts @@ -465,7 +465,7 @@ export class DebugService implements IDebugService { nls.localize({ key: 'installAdditionalDebuggers', comment: ['Placeholder is the debug type, so for example "node", "python"'] }, "Install {0} Extension", resolvedConfig.type), undefined, true, - async () => this.commandService.executeCommand('debug.installAdditionalDebuggers') + async () => this.commandService.executeCommand('debug.installAdditionalDebuggers', resolvedConfig?.type) )); await this.showError(message, actionList);