mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-20 19:14:10 +01:00
Fix not putting focus in the integrated terminal when it's first shown.
This is a little hacky and we might want to rethink it but should be safe and fine
This commit is contained in:
@@ -59,6 +59,7 @@ export interface ITerminalTab {
|
||||
onDisposed: Event<ITerminalTab>;
|
||||
onInstancesChanged: Event<void>;
|
||||
|
||||
setWillFocus(focus: boolean): void;
|
||||
focusPreviousPane(): void;
|
||||
focusNextPane(): void;
|
||||
resizePane(direction: Direction): void;
|
||||
|
||||
@@ -219,6 +219,7 @@ export class TerminalTab extends Disposable implements ITerminalTab {
|
||||
|
||||
private _activeInstanceIndex: number;
|
||||
private _isVisible: boolean = false;
|
||||
private _willFocus: boolean = false;
|
||||
|
||||
public get terminalInstances(): ITerminalInstance[] { return this._terminalInstances; }
|
||||
|
||||
@@ -248,6 +249,16 @@ export class TerminalTab extends Disposable implements ITerminalTab {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Focus the current active instance, or if there isn't one yet, the first instance added
|
||||
*/
|
||||
setWillFocus(focus: boolean): void {
|
||||
this._willFocus = focus;
|
||||
if (focus && this.activeInstance) {
|
||||
this.activeInstance.focusWhenReady();
|
||||
}
|
||||
}
|
||||
|
||||
public addInstance(shellLaunchConfigOrInstance: IShellLaunchConfig | ITerminalInstance): void {
|
||||
let instance: ITerminalInstance;
|
||||
if ('id' in shellLaunchConfigOrInstance) {
|
||||
@@ -263,6 +274,10 @@ export class TerminalTab extends Disposable implements ITerminalTab {
|
||||
}
|
||||
|
||||
this._onInstancesChanged.fire();
|
||||
|
||||
if (this.terminalInstances.length === 1 && this._willFocus) {
|
||||
instance.focusWhenReady();
|
||||
}
|
||||
}
|
||||
|
||||
public dispose(): void {
|
||||
|
||||
@@ -67,6 +67,13 @@ export class TerminalViewPane extends ViewPane {
|
||||
}
|
||||
this._onDidChangeViewWelcomeState.fire();
|
||||
});
|
||||
|
||||
this._register(this.onDidFocus(() => {
|
||||
this._terminalService.getActiveTab()?.setWillFocus(true);
|
||||
}));
|
||||
this._register(this.onDidBlur(() => {
|
||||
this._terminalService.getActiveTab()?.setWillFocus(false);
|
||||
}));
|
||||
}
|
||||
|
||||
protected renderBody(container: HTMLElement): void {
|
||||
@@ -212,10 +219,6 @@ export class TerminalViewPane extends ViewPane {
|
||||
return super.getActionViewItem(action);
|
||||
}
|
||||
|
||||
public focus(): void {
|
||||
this._terminalService.getActiveInstance()?.focusWhenReady(true);
|
||||
}
|
||||
|
||||
public focusFindWidget() {
|
||||
const activeInstance = this._terminalService.getActiveInstance();
|
||||
if (activeInstance && activeInstance.hasSelection() && activeInstance.selection!.indexOf('\n') === -1) {
|
||||
|
||||
Reference in New Issue
Block a user