提交 49ef020f 编写于 作者: I isidor

debug start view: debugStartLanguage context key

fixes #85548
上级 68a10136
......@@ -11,7 +11,6 @@ import * as objects from 'vs/base/common/objects';
import { URI as uri } from 'vs/base/common/uri';
import * as resources from 'vs/base/common/resources';
import { IJSONSchema } from 'vs/base/common/jsonSchema';
import * as editorCommon from 'vs/editor/common/editorCommon';
import { ITextModel } from 'vs/editor/common/model';
import { IEditor } from 'vs/workbench/common/editor';
import { IStorageService, StorageScope } from 'vs/platform/storage/common/storage';
......@@ -434,15 +433,8 @@ export class ConfigurationManager implements IConfigurationManager {
return this.debuggers.filter(dbg => strings.equalsIgnoreCase(dbg.type, type)).pop();
}
getDebuggerLabelsForEditor(editor: editorCommon.IEditor | undefined): string[] {
if (isCodeEditor(editor)) {
const model = editor.getModel();
const language = model ? model.getLanguageIdentifier().language : undefined;
return this.debuggers.filter(a => language && a.languages && a.languages.indexOf(language) >= 0).map(d => d.label);
}
return [];
isDebuggerInterestedInLanguage(language: string): boolean {
return this.debuggers.filter(a => language && a.languages && a.languages.indexOf(language) >= 0).length > 0;
}
async guessDebugger(type?: string): Promise<Debugger | undefined> {
......
......@@ -21,14 +21,17 @@ import { IOpenerService } from 'vs/platform/opener/common/opener';
import { WorkbenchStateContext } from 'vs/workbench/browser/contextkeys';
import { OpenFolderAction, OpenFileAction, OpenFileFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
import { isMacintosh } from 'vs/base/common/platform';
import { isCodeEditor } from 'vs/editor/browser/editorBrowser';
const CONTEXT_DEBUGGER_INTERESTED = new RawContextKey<boolean>('debuggerInterested', false);
const CONTEXT_DEBUG_START_LANGUAGE = new RawContextKey<string>('debugStartLanguage', undefined);
const CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR = new RawContextKey<boolean>('debuggerInterestedInActiveEditor', false);
export class StartView extends ViewPane {
static ID = 'workbench.debug.startView';
static LABEL = localize('start', "Start");
private debugStartLanguageContext: IContextKey<string>;
private debuggerInterestedContext: IContextKey<boolean>;
constructor(
......@@ -46,11 +49,20 @@ export class StartView extends ViewPane {
) {
super({ ...(options as IViewPaneOptions), ariaHeaderLabel: localize('debugStart', "Debug Start Section") }, keybindingService, contextMenuService, configurationService, contextKeyService, viewDescriptorService, instantiationService, openerService, themeService);
this.debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED.bindTo(contextKeyService);
this.debugStartLanguageContext = CONTEXT_DEBUG_START_LANGUAGE.bindTo(contextKeyService);
this.debuggerInterestedContext = CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR.bindTo(contextKeyService);
const setContextKey = () => {
const activeEditor = this.editorService.activeTextEditorWidget;
const debuggerLabels = this.debugService.getConfigurationManager().getDebuggerLabelsForEditor(activeEditor);
this.debuggerInterestedContext.set(debuggerLabels.length > 0);
const editor = this.editorService.activeTextEditorWidget;
if (isCodeEditor(editor)) {
const model = editor.getModel();
const language = model ? model.getLanguageIdentifier().language : undefined;
if (language && this.debugService.getConfigurationManager().isDebuggerInterestedInLanguage(language)) {
this.debugStartLanguageContext.set(language);
this.debuggerInterestedContext.set(true);
return;
}
}
this.debuggerInterestedContext.set(false);
};
this._register(editorService.onDidActiveEditorChange(setContextKey));
this._register(this.debugService.getConfigurationManager().onDidRegisterDebugger(setContextKey));
......@@ -64,7 +76,7 @@ export class StartView extends ViewPane {
const viewsRegistry = Registry.as<IViewsRegistry>(Extensions.ViewsRegistry);
viewsRegistry.registerViewWelcomeContent(StartView.ID, {
content: localize('openAFileWhichCanBeDebugged', "[Open a file](command:{0}) which can be debugged or run.", isMacintosh ? OpenFileFolderAction.ID : OpenFileAction.ID),
when: CONTEXT_DEBUGGER_INTERESTED.toNegated()
when: CONTEXT_DEBUGGER_INTERESTED_IN_ACTIVE_EDITOR
});
viewsRegistry.registerViewWelcomeContent(StartView.ID, {
......
......@@ -647,7 +647,7 @@ export interface IConfigurationManager {
activateDebuggers(activationEvent: string, debugType?: string): Promise<void>;
getDebuggerLabelsForEditor(editor: editorCommon.IEditor | undefined): string[];
isDebuggerInterestedInLanguage(language: string): boolean;
hasDebugConfigurationProvider(debugType: string): boolean;
registerDebugConfigurationProvider(debugConfigurationProvider: IDebugConfigurationProvider): IDisposable;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册