This commit is contained in:
parent
1f76da28f6
commit
a53919b8e9
3 changed files with 27 additions and 2 deletions
|
@ -226,7 +226,7 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
protected readonly _instantiationService: IInstantiationService;
|
||||
protected readonly _contextKeyService: IContextKeyService;
|
||||
private readonly _notificationService: INotificationService;
|
||||
private readonly _codeEditorService: ICodeEditorService;
|
||||
protected readonly _codeEditorService: ICodeEditorService;
|
||||
private readonly _commandService: ICommandService;
|
||||
private readonly _themeService: IThemeService;
|
||||
|
||||
|
@ -1048,6 +1048,10 @@ export class CodeEditorWidget extends Disposable implements editorBrowser.ICodeE
|
|||
return;
|
||||
}
|
||||
|
||||
this._triggerCommand(handlerId, payload);
|
||||
}
|
||||
|
||||
protected _triggerCommand(handlerId: string, payload: any): void {
|
||||
this._commandService.executeCommand(handlerId, payload);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ import { StandaloneThemeServiceImpl } from 'vs/editor/standalone/browser/standal
|
|||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ILanguageSelection, IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { StandaloneCodeEditorServiceImpl } from 'vs/editor/standalone/browser/standaloneCodeServiceImpl';
|
||||
|
||||
/**
|
||||
* Description of an action contribution
|
||||
|
@ -363,6 +364,20 @@ export class StandaloneCodeEditor extends CodeEditorWidget implements IStandalon
|
|||
|
||||
return toDispose;
|
||||
}
|
||||
|
||||
protected override _triggerCommand(handlerId: string, payload: any): void {
|
||||
if (this._codeEditorService instanceof StandaloneCodeEditorServiceImpl) {
|
||||
// Help commands find this editor as the active editor
|
||||
try {
|
||||
this._codeEditorService.setActiveCodeEditor(this);
|
||||
super._triggerCommand(handlerId, payload);
|
||||
} finally {
|
||||
this._codeEditorService.setActiveCodeEditor(null);
|
||||
}
|
||||
} else {
|
||||
super._triggerCommand(handlerId, payload);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export class StandaloneEditor extends StandaloneCodeEditor implements IStandaloneCodeEditor {
|
||||
|
|
|
@ -18,6 +18,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
|
|||
export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
||||
|
||||
private readonly _editorIsOpen: IContextKey<boolean>;
|
||||
private _activeCodeEditor: ICodeEditor | null;
|
||||
|
||||
constructor(
|
||||
styleSheet: GlobalStyleSheet | null,
|
||||
|
@ -28,6 +29,7 @@ export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
|||
this.onCodeEditorAdd(() => this._checkContextKey());
|
||||
this.onCodeEditorRemove(() => this._checkContextKey());
|
||||
this._editorIsOpen = contextKeyService.createKey('editorIsOpen', false);
|
||||
this._activeCodeEditor = null;
|
||||
}
|
||||
|
||||
private _checkContextKey(): void {
|
||||
|
@ -41,8 +43,12 @@ export class StandaloneCodeEditorServiceImpl extends CodeEditorServiceImpl {
|
|||
this._editorIsOpen.set(hasCodeEditor);
|
||||
}
|
||||
|
||||
public setActiveCodeEditor(activeCodeEditor: ICodeEditor | null): void {
|
||||
this._activeCodeEditor = activeCodeEditor;
|
||||
}
|
||||
|
||||
public getActiveCodeEditor(): ICodeEditor | null {
|
||||
return null; // not supported in the standalone case
|
||||
return this._activeCodeEditor;
|
||||
}
|
||||
|
||||
public openCodeEditor(input: IResourceEditorInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
|
||||
|
|
Loading…
Reference in a new issue