mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-12 17:48:19 +01:00
Add isDirty
This commit is contained in:
@@ -55,7 +55,8 @@ export class MainThreadEditorTabs {
|
||||
resource: editor instanceof SideBySideEditorInput ? EditorResourceAccessor.getCanonicalUri(editor, { supportSideBySide: SideBySideEditor.PRIMARY }) : EditorResourceAccessor.getCanonicalUri(editor),
|
||||
editorId,
|
||||
additionalResourcesAndViewIds: [],
|
||||
isActive: group.isActive(editor)
|
||||
isActive: group.isActive(editor),
|
||||
isDirty: editor.isDirty()
|
||||
};
|
||||
tab.additionalResourcesAndViewIds.push({ resource: tab.resource, viewId: tab.editorId });
|
||||
if (editor instanceof SideBySideEditorInput) {
|
||||
@@ -173,6 +174,14 @@ export class MainThreadEditorTabs {
|
||||
this._groupModel.get(groupId)!.activeTab = activeTab;
|
||||
}
|
||||
|
||||
private _onDidTabDirty(groupId: number, editorIndex: number, editor: EditorInput) {
|
||||
const tab = this._groupModel.get(groupId)?.tabs[editorIndex];
|
||||
if (!tab) {
|
||||
return;
|
||||
}
|
||||
tab.isDirty = editor.isDirty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the model from scratch based on the current state of the editor service.
|
||||
*/
|
||||
@@ -254,6 +263,11 @@ export class MainThreadEditorTabs {
|
||||
this._onDidTabActiveChange(event.groupId, event.editorIndex);
|
||||
break;
|
||||
}
|
||||
case GroupModelChangeKind.EDITOR_DIRTY:
|
||||
if (event.editorIndex && event.editor) {
|
||||
this._onDidTabDirty(event.groupId, event.editorIndex, event.editor);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// If it's not an optimized case we rebuild the tabs model from scratch
|
||||
this._createTabsModel();
|
||||
|
||||
@@ -631,6 +631,7 @@ export interface IEditorTabDto {
|
||||
resource?: UriComponents;
|
||||
editorId?: string;
|
||||
isActive: boolean;
|
||||
isDirty: boolean;
|
||||
additionalResourcesAndViewIds: { resource?: UriComponents; viewId?: string }[];
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ export interface IEditorTab {
|
||||
resource: vscode.Uri | undefined;
|
||||
viewId: string | undefined;
|
||||
isActive: boolean;
|
||||
isDirty: boolean;
|
||||
additionalResourcesAndViewIds: { resource: vscode.Uri | undefined; viewId: string | undefined }[];
|
||||
move(index: number, viewColumn: ViewColumn): Promise<void>;
|
||||
close(): Promise<void>;
|
||||
@@ -91,6 +92,7 @@ export class ExtHostEditorTabs implements IExtHostEditorTabs {
|
||||
additionalResourcesAndViewIds: tabDto.additionalResourcesAndViewIds.map(({ resource, viewId }) => ({ resource: URI.revive(resource), viewId })),
|
||||
viewId: tabDto.editorId,
|
||||
isActive: tabDto.isActive,
|
||||
isDirty: tabDto.isDirty,
|
||||
move: async (index: number, viewColumn: ViewColumn) => {
|
||||
this._proxy.$moveTab(tabDto, index, typeConverters.ViewColumn.from(viewColumn));
|
||||
// TODO: Need an on did change tab event at the group level
|
||||
|
||||
+10
-5
@@ -50,6 +50,11 @@ declare module 'vscode' {
|
||||
*/
|
||||
readonly isActive: boolean;
|
||||
|
||||
/**
|
||||
* Whether or not the dirty indicator is present on the tab
|
||||
*/
|
||||
readonly isDirty: boolean;
|
||||
|
||||
/**
|
||||
* Moves a tab to the given index within the column.
|
||||
* If the index is out of range, the tab will be moved to the end of the column.
|
||||
@@ -77,7 +82,7 @@ declare module 'vscode' {
|
||||
/**
|
||||
* All the groups within the group container
|
||||
*/
|
||||
all: TabGroup[];
|
||||
readonly all: TabGroup[];
|
||||
|
||||
/**
|
||||
* An {@link Event} which fires when a group changes.
|
||||
@@ -90,21 +95,21 @@ declare module 'vscode' {
|
||||
/**
|
||||
* Whether or not the group is currently active
|
||||
*/
|
||||
isActive: boolean;
|
||||
readonly isActive: boolean;
|
||||
|
||||
/**
|
||||
* The view column of the groups
|
||||
*/
|
||||
viewColumn: ViewColumn;
|
||||
readonly viewColumn: ViewColumn;
|
||||
|
||||
/**
|
||||
* The active tab within the group
|
||||
*/
|
||||
activeTab: Tab | undefined;
|
||||
readonly activeTab: Tab | undefined;
|
||||
|
||||
/**
|
||||
* The list of tabs contained within the group
|
||||
*/
|
||||
tabs: Tab[];
|
||||
readonly tabs: Tab[];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user