mirror of
https://github.com/Microsoft/vscode
synced 2024-08-28 13:29:44 +00:00
open or focus editor
This commit is contained in:
parent
71e9f1f7cb
commit
6efcb92e34
|
@ -197,6 +197,7 @@ export interface ITerminalEditorService extends ITerminalInstanceHost, ITerminal
|
|||
readonly instances: readonly ITerminalInstance[];
|
||||
|
||||
openEditor(instance: ITerminalInstance): Promise<void>;
|
||||
openOrFocusEditor(instance: ITerminalInstance): Promise<void>;
|
||||
getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput): TerminalEditorInput;
|
||||
detachActiveEditorInstance(): ITerminalInstance;
|
||||
detachInstance(instance: ITerminalInstance): void;
|
||||
|
|
|
@ -145,6 +145,20 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor
|
|||
);
|
||||
}
|
||||
|
||||
async openOrFocusEditor(instance: ITerminalInstance): Promise<void> {
|
||||
const input = this.getOrCreateEditorInput(instance);
|
||||
console.log(this._editorService.activeEditorPane?.group);
|
||||
if (!this._editorService.activeEditorPane?.group.contains(input)) {
|
||||
instance.focus();
|
||||
return;
|
||||
}
|
||||
await this._editorService.openEditor(input, {
|
||||
pinned: true,
|
||||
forceReload: true
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
getOrCreateEditorInput(instance: ITerminalInstance | SerializedTerminalEditorInput, isFutureSplit: boolean = false): TerminalEditorInput {
|
||||
let cachedEditor;
|
||||
if ('id' in instance) {
|
||||
|
|
|
@ -121,7 +121,7 @@ export class TerminalQuickAccessProvider extends PickerQuickAccessProvider<IPick
|
|||
},
|
||||
accept: (keyMod, event) => {
|
||||
if (terminal.target === TerminalLocation.Editor) {
|
||||
terminal.focus();
|
||||
this._terminalEditorService.openOrFocusEditor(terminal);
|
||||
this._terminalEditorService.setActiveInstance(terminal);
|
||||
} else {
|
||||
this._terminalGroupService.showPanel(!event.inBackground);
|
||||
|
|
Loading…
Reference in a new issue