Skip to content

Commit

Permalink
Smooth the flow of installing new debuggers
Browse files Browse the repository at this point in the history
fixes #119110
  • Loading branch information
isidorn committed Apr 16, 2021
1 parent d66d392 commit 78872ce
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
22 changes: 14 additions & 8 deletions src/vs/workbench/contrib/debug/browser/debugAdapterManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,33 +225,39 @@ 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];
}
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;
});
Expand Down
8 changes: 6 additions & 2 deletions src/vs/workbench/contrib/debug/browser/debugCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
});
Expand Down
2 changes: 1 addition & 1 deletion src/vs/workbench/contrib/debug/browser/debugService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 78872ce

Please sign in to comment.