parent
628b4d4635
commit
cae22b8826
|
@ -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,9 +193,14 @@ export function registerTerminalActions() {
|
|||
|
||||
if (instance) {
|
||||
terminalService.setActiveInstance(instance);
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -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,7 +991,11 @@ export function registerTerminalActions() {
|
|||
config: { attachPersistentProcess: selected.term }
|
||||
});
|
||||
terminalService.setActiveInstance(instance);
|
||||
terminalGroupService.showPanel(true);
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1205,8 +1213,12 @@ export function registerTerminalActions() {
|
|||
return;
|
||||
}
|
||||
terminalService.setActiveInstance(instance);
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
return accessor.get(ITerminalGroupService).showPanel(true);
|
||||
}
|
||||
}
|
||||
return accessor.get(ITerminalGroupService).showPanel(true);
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
|
@ -1462,8 +1474,12 @@ export function registerTerminalActions() {
|
|||
return undefined;
|
||||
}
|
||||
const instance = terminalService.splitInstance(activeInstance, options?.config, cwd);
|
||||
if (instance?.target !== TerminalLocation.Editor) {
|
||||
return terminalGroupService.showPanel(true);
|
||||
if (instance) {
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
instance.focusWhenReady();
|
||||
} else {
|
||||
return terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -1663,8 +1679,12 @@ export function registerTerminalActions() {
|
|||
instance = terminalService.createTerminal(eventOrOptions);
|
||||
}
|
||||
terminalService.setActiveInstance(instance);
|
||||
if (instance.target === TerminalLocation.Editor) {
|
||||
await instance.focusWhenReady(true);
|
||||
} else {
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
}
|
||||
await terminalGroupService.showPanel(true);
|
||||
}
|
||||
});
|
||||
registerAction2(class extends Action2 {
|
||||
|
@ -1922,10 +1942,9 @@ export function registerTerminalActions() {
|
|||
if (quickSelectProfiles) {
|
||||
const profile = quickSelectProfiles.find(profile => profile.profileName === profileSelection);
|
||||
if (profile) {
|
||||
const instance = terminalService.createTerminal(
|
||||
{
|
||||
config: profile
|
||||
});
|
||||
const instance = terminalService.createTerminal({
|
||||
config: profile
|
||||
});
|
||||
terminalService.setActiveInstance(instance);
|
||||
} else {
|
||||
console.warn(`No profile with name "${profileSelection}"`);
|
||||
|
|
|
@ -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,20 +158,18 @@ 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) {
|
||||
const pane = this._viewsService.getActiveViewWithId(TERMINAL_VIEW_ID)
|
||||
?? await this._viewsService.openView(TERMINAL_VIEW_ID, focus);
|
||||
pane?.setExpanded(true);
|
||||
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);
|
||||
|
||||
if (focus) {
|
||||
// Do the focus call asynchronously as going through the
|
||||
// command palette will force editor focus
|
||||
await timeout(0);
|
||||
const instance = this.activeInstance;
|
||||
if (instance) {
|
||||
await instance.focusWhenReady(true);
|
||||
}
|
||||
if (focus) {
|
||||
// Do the focus call asynchronously as going through the
|
||||
// command palette will force editor focus
|
||||
await timeout(0);
|
||||
const instance = this.activeInstance;
|
||||
if (instance) {
|
||||
await instance.focusWhenReady(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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