Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test: terminal location API #131278

Closed
3 tasks done
meganrogge opened this issue Aug 20, 2021 · 4 comments
Closed
3 tasks done

Test: terminal location API #131278

meganrogge opened this issue Aug 20, 2021 · 4 comments

Comments

@meganrogge
Copy link
Contributor

meganrogge commented Aug 20, 2021

Refs #45407

Complexity: 3

Authors: @meganrogge, @Tyriar

Create Issue


With proposed API enabled, use the extension-terminal-sample to test the following:


	export interface TerminalOptions {
		location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
	}

	export interface ExtensionTerminalOptions {
		location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
	}

	export enum TerminalLocation {
		Panel = 0,
		Editor = 1,
	}

	export interface TerminalEditorLocationOptions {
		/**
		 * A view column in which the {@link Terminal terminal} should be shown in the editor area.
		 * Use {@link ViewColumn.Active active} to open in the active editor group, other values are
		 * adjusted to be `Min(column, columnCount + 1)`, the
		 * {@link ViewColumn.Active active}-column is not adjusted. Use
		 * {@linkcode ViewColumn.Beside} to open the editor to the side of the currently active one.
		 */
		viewColumn: ViewColumn;
		/**
		 * An optional flag that when `true` will stop the {@link Terminal} from taking focus.
		 */
		preserveFocus?: boolean;
	}

	export interface TerminalSplitLocationOptions {
		/**
		 * The parent terminal to split this terminal beside. This works whether the parent terminal
		 * is in the panel or the editor area.
		 */
		parentTerminal: Terminal;
	}

Also, be sure to test splitting terminals in the editor and panel as that should all still work properly and there were a lot of changes that went into this work.

@stevencl
Copy link
Member

I expect that this is probably just my misunderstanding of how viewColumn works but I expected this code to create a new terminal in the 4th editor. If I have a 2 x 3 grid of editors (2 rows of 3 columns) I expected this to create a new terminal in the first editor group in the second row. But instead it creates a new terminal next to whatever editor is active.

context.subscriptions.push(vscode.commands.registerCommand('terminaltest.createTerminal', () => {
	let termEdLocation:vscode.TerminalEditorLocationOptions = {
		viewColumn: vscode.ViewColumn.Four,
		preserveFocus: false
	};
	vscode.window.createTerminal({
		name: `Ext Terminal #${NEXT_TERM_ID++}`,
		location: termEdLocation
	} as any);
	vscode.window.showInformationMessage('Hello World 2!');
}));

@weinand
Copy link
Contributor

weinand commented Aug 24, 2021

@meganrogge for testing the TerminalSplitLocationOptions.parentTerminal property, my extension code passed the vscode.window.activeTerminal. When running the code I noticed that activeTerminal only tracks the terminals of the panel, but not the ones from the editor area. If this is the intended behavior, then the vscode.window.activeTerminal comment needs to be updated.

@meganrogge
Copy link
Contributor Author

meganrogge commented Aug 24, 2021

@Tyriar I debugged and see this.activeTerminal getting appropriately updated when I create a terminal in the editor area or panel or when I focus and switch between them. So not sure how it's not working

public async $acceptActiveTerminalChanged(id: number | null): Promise<void> {
		const original = this._activeTerminal;
		if (id === null) {
			this._activeTerminal = undefined;
			if (original !== this._activeTerminal) {
				this._onDidChangeActiveTerminal.fire(this._activeTerminal);
			}
			return;
		}
		const terminal = this._getTerminalById(id);
		if (terminal) {
			this._activeTerminal = terminal;
			if (original !== this._activeTerminal) {
				this._onDidChangeActiveTerminal.fire(this._activeTerminal.value);
			}
		}
	}

@weinand
Copy link
Contributor

weinand commented Aug 24, 2021

@meganrogge I was using this code in the "helloWorld" command of the standard "hello world" extension:

		const terminal = vscode.window.createTerminal({
			name: 'august',
			message: 'a message',
			location: {
				viewColumn: ViewColumn.Beside,
				parentTerminal: vscode.window.activeTerminal
			}
		});

When running the "helloWorld" command, new terminals are always added to the panel but not to the editor area. Maybe my interpretation that "activeTerminal only tracks the terminals of the panel" is wrong...

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants