parent
628b4d4635
commit
cae22b8826
8 changed files with 55 additions and 38 deletions
|
@ -251,7 +251,7 @@ export interface ITerminalGroupService extends ITerminalInstanceHost, ITerminalF
|
|||
|
||||
setContainer(container: HTMLElement): void;
|
||||
|
||||
showPanel(focus?: boolean, force?: boolean): Promise<void>;
|
||||
showPanel(focus?: boolean): Promise<void>;
|
||||
hidePanel(): void;
|
||||
focusTabs(): void;
|
||||
showTabs(): void;
|
||||
|
|
|
@ -193,10 +193,15 @@ export function registerTerminalActions() {
|
|||
|
||||
if (instance) {
|
||||
terminalService.setActiveInstance(instance);
|
||||
}
|
||||
}
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
registerAction2(class extends Action2 {
|
||||
|
@ -211,10 +216,9 @@ export function registerTerminalActions() {
|
|||
}
|
||||
async run(accessor: ServicesAccessor) {
|
||||
const terminalService = accessor.get(ITerminalService);
|
||||
// TODO: Await openEditor
|
||||
terminalService.createTerminal({
|
||||
await terminalService.createTerminal({
|
||||
target: TerminalLocation.Editor
|
||||
});
|
||||
}).focusWhenReady();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -987,9 +991,13 @@ export function registerTerminalActions() {
|
|||
config: { attachPersistentProcess: selected.term }
|
||||
});
|
||||
terminalService.setActiveInstance(instance);
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -1205,9 +1213,13 @@ export function registerTerminalActions() {
|
|||
return;
|
||||
}
|
||||
terminalService.setActiveInstance(instance);
|
||||
}
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
return accessor.get(ITerminalGroupService).showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -1462,10 +1474,14 @@ export function registerTerminalActions() {
|
|||
return undefined;
|
||||
}
|
||||
const instance = terminalService.splitInstance(activeInstance, options?.config, cwd);
|
||||
if (instance?.target !== TerminalLocation.Editor) {
|
||||
if (instance) {
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
instance.focusWhenReady();
|
||||
} else {
|
||||
return terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -1663,9 +1679,13 @@ export function registerTerminalActions() {
|
|||
instance = terminalService.createTerminal(eventOrOptions);
|
||||
}
|
||||
terminalService.setActiveInstance(instance);
|
||||
}
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
constructor() {
|
||||
|
@ -1922,8 +1942,7 @@ export function registerTerminalActions() {
|
|||
if (quickSelectProfiles) {
|
||||
const profile = quickSelectProfiles.find(profile => profile.profileName === profileSelection);
|
||||
if (profile) {
|
||||
const instance = terminalService.createTerminal(
|
||||
{
|
||||
const instance = terminalService.createTerminal({
|
||||
config: profile
|
||||
});
|
||||
terminalService.setActiveInstance(instance);
|
||||
|
|
|
@ -31,6 +31,7 @@ export class TerminalEditorInput extends EditorInput {
|
|||
|
||||
override copy(): IEditorInput {
|
||||
const instance = this._copyInstance || this._terminalInstanceService.createInstance({}, TerminalLocation.Editor);
|
||||
instance.focusWhenReady();
|
||||
this._copyInstance = undefined;
|
||||
return this._instantiationService.createInstance(TerminalEditorInput, instance);
|
||||
}
|
||||
|
|
|
@ -126,9 +126,7 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor
|
|||
} else {
|
||||
this._activeInstanceIndex = this.instances.findIndex(e => e === instance);
|
||||
}
|
||||
const newActiveInstance = this.activeInstance;
|
||||
newActiveInstance?.focus();
|
||||
this._onDidChangeActiveInstance.fire(newActiveInstance);
|
||||
this._onDidChangeActiveInstance.fire(this.activeInstance);
|
||||
}
|
||||
|
||||
async openEditor(instance: ITerminalInstance): Promise<void> {
|
||||
|
|
|
@ -11,10 +11,9 @@ import { FindReplaceState } from 'vs/editor/contrib/find/findState';
|
|||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IShellLaunchConfig, TerminalLocation, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { IShellLaunchConfig, TerminalSettingId } from 'vs/platform/terminal/common/terminal';
|
||||
import { IViewDescriptorService, IViewsService, ViewContainerLocation } from 'vs/workbench/common/views';
|
||||
import { ITerminalFindHost, ITerminalGroup, ITerminalGroupService, ITerminalInstance } from 'vs/workbench/contrib/terminal/browser/terminal';
|
||||
import { TerminalConfigHelper } from 'vs/workbench/contrib/terminal/browser/terminalConfigHelper';
|
||||
import { TerminalGroup } from 'vs/workbench/contrib/terminal/browser/terminalGroup';
|
||||
import { TerminalViewPane } from 'vs/workbench/contrib/terminal/browser/terminalView';
|
||||
import { KEYBINDING_CONTEXT_GROUP_TERMINAL_COUNT, KEYBINDING_CONTEXT_TERMINAL_GROUP_COUNT, KEYBINDING_CONTEXT_TERMINAL_TABS_MOUSE, TERMINAL_VIEW_ID } from 'vs/workbench/contrib/terminal/common/terminal';
|
||||
|
@ -36,8 +35,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
|
|||
|
||||
private _findState: FindReplaceState;
|
||||
|
||||
private _configHelper: TerminalConfigHelper;
|
||||
|
||||
private readonly _onDidChangeActiveGroup = new Emitter<ITerminalGroup | undefined>();
|
||||
readonly onDidChangeActiveGroup = this._onDidChangeActiveGroup.event;
|
||||
private readonly _onDidDisposeGroup = new Emitter<ITerminalGroup>();
|
||||
|
@ -76,8 +73,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
|
|||
this.onDidChangeInstances(() => this._terminalCountContextKey.set(this.instances.length));
|
||||
|
||||
this._findState = new FindReplaceState();
|
||||
|
||||
this._configHelper = _instantiationService.createInstance(TerminalConfigHelper);
|
||||
}
|
||||
|
||||
hidePanel(): void {
|
||||
|
@ -163,8 +158,7 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
|
|||
return group;
|
||||
}
|
||||
|
||||
async showPanel(focus?: boolean, force?: boolean): Promise<void> {
|
||||
if (this._configHelper.config.defaultLocation !== TerminalLocation.Editor || force) {
|
||||
async showPanel(focus?: boolean): Promise<void> {
|
||||
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID)
|
||||
?? await this._viewsService.openView(TERMINAL_VIEW_ID, focus);
|
||||
pane?.setExpanded(true);
|
||||
|
@ -179,7 +173,6 @@ export class TerminalGroupService extends Disposable implements ITerminalGroupSe
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
findNext(): void {
|
||||
const pane = this._viewsService.getActiveViewWithId<TerminalViewPane>(TERMINAL_VIEW_ID);
|
||||
|
|
|
@ -133,6 +133,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
private _areLinksReady: boolean = false;
|
||||
private _initialDataEvents: string[] | undefined = [];
|
||||
private _containerReadyBarrier: AutoOpenBarrier;
|
||||
private _attachBarrier: AutoOpenBarrier;
|
||||
|
||||
private _messageTitleDisposable: IDisposable | undefined;
|
||||
|
||||
|
@ -297,6 +298,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
this._register(toDisposable(() => this._dndObserver?.dispose()));
|
||||
|
||||
this._containerReadyBarrier = new AutoOpenBarrier(Constants.WaitForContainerThreshold);
|
||||
this._attachBarrier = new AutoOpenBarrier(1000);
|
||||
this._xtermReadyPromise = this._createXterm();
|
||||
this._xtermReadyPromise.then(async () => {
|
||||
// Wait for a period to allow a container to be ready
|
||||
|
@ -647,6 +649,8 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
return;
|
||||
}
|
||||
|
||||
this._attachBarrier.open();
|
||||
|
||||
// Attach has not occurred yet
|
||||
if (!this._wrapperElement) {
|
||||
return this._attachToElement(container);
|
||||
|
@ -1017,6 +1021,7 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
|
|||
|
||||
async focusWhenReady(force?: boolean): Promise<void> {
|
||||
await this._xtermReadyPromise;
|
||||
await this._attachBarrier.wait();
|
||||
this.focus(force);
|
||||
}
|
||||
|
||||
|
|
|
@ -697,7 +697,7 @@ export class TerminalService implements ITerminalService {
|
|||
// Fire events
|
||||
this._onDidChangeInstances.fire();
|
||||
this._onActiveGroupChanged.fire(this._terminalGroupService.activeGroup);
|
||||
this._terminalGroupService.showPanel(true, true);
|
||||
this._terminalGroupService.showPanel(true);
|
||||
}
|
||||
|
||||
protected _initInstanceListeners(instance: ITerminalInstance): void {
|
||||
|
|
|
@ -193,7 +193,8 @@ export class TerminalViewPane extends ViewPane {
|
|||
run: () => {
|
||||
const instance = this._terminalGroupService.activeInstance;
|
||||
if (instance) {
|
||||
return this._terminalService.splitInstance(instance);
|
||||
const newInstance = this._terminalService.splitInstance(instance);
|
||||
return newInstance?.focusWhenReady();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue