Skip to content

Tab model API #133532

@lramos15

Description

@lramos15

There are many cases where the user wants to be able to either get the state of opened editors / tabs or modify it. This has been conveyed in multiple issues such as #15178. This issue will serve to track the proposal and API development for an API which allows the reading and modification of the tabs.

The current proposal is:

//#region https://github.com/Microsoft/vscode/issues/15178
/**
* Represents a tab within the window
*/
export interface Tab {
/**
* The text displayed on the tab
*/
readonly label: string;
/**
* The index of the tab within the view column
*/
readonly index: number;
/**
* The column the tab belongs to
*/
readonly viewColumn: ViewColumn;
/**
* The resource represented by the tab if availble.
* Note: Not all tabs have a resource associated with them.
*/
readonly resource?: Uri;
/**
* The identifier of the view contained in the tab
* This is equivalent to `viewType` for custom editors and `notebookType` for notebooks.
* The built-in text editor has an id of 'default' for all configurations.
*/
readonly viewId?: string;
/**
* Whether or not the tab is currently active
* Dictated by being the selected tab in the active group
*/
readonly isActive: boolean;
/**
* Closes the tab object
*/
close(): void;
/**
* Sets the label of the tab
*/
setLabel(label: string): void;
/**
* Moves the tab to the new index and view column
* @param index The new index of the tab within the current group
* @param viewColumn The new view column of the tab.
*/
move(index: number, viewColumn: ViewColumn): void;
}
export namespace window {
/**
* A list of all opened tabs
* Ordered from left to right
*/
export const tabs: readonly Tab[];
/**
* The currently active tab
* Undefined if no tabs are currently opened
*/
export const activeTab: Tab | undefined;
/**
* An {@link Event} which fires when the array of {@link window.tabs tabs}
* has changed.
*/
export const onDidChangeTabs: Event<readonly Tab[]>;
/**
* An {@link Event} which fires when the {@link window.activeTab activeTab}
* has changed.
*/
export const onDidChangeActiveTab: Event<Tab | undefined>;
/**
* Opens a tab
* @param tab The object representing the tab you want to open
* @returns The opened tab
*/
export function openTab(tab: Exclude<Tab, Function>): Thenable<Tab>;
}
//#endregion

Metadata

Metadata

Assignees

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions