From ea22cfbad505799e2178e9df1eb65e30fb28e745 Mon Sep 17 00:00:00 2001 From: aamunger Date: Wed, 21 Jun 2023 10:51:56 -0700 Subject: [PATCH] check the model for modified property --- .../contrib/interactive/browser/interactiveEditorInput.ts | 2 +- src/vs/workbench/contrib/notebook/common/notebookCommon.ts | 1 + .../workbench/contrib/notebook/common/notebookEditorModel.ts | 4 ++++ .../contrib/notebook/test/browser/testNotebookEditor.ts | 4 ++++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts b/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts index 462f4008bb4..49e3601838a 100644 --- a/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts +++ b/src/vs/workbench/contrib/interactive/browser/interactiveEditorInput.ts @@ -220,7 +220,7 @@ export class InteractiveEditorInput extends EditorInput implements ICompositeNot } override isModified() { - return true; + return this._editorModelReference?.isModified() ?? false; } override dispose() { diff --git a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts index 306c11a4567..78a363cdf05 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookCommon.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookCommon.ts @@ -797,6 +797,7 @@ export interface INotebookEditorModel extends IEditorModel { readonly notebook: INotebookTextModel | undefined; isResolved(): this is IResolvedNotebookEditorModel; isDirty(): boolean; + isModified(): boolean; isReadonly(): boolean | IMarkdownString; isOrphaned(): boolean; hasAssociatedFilePath(): boolean; diff --git a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts index e0c3352be75..390fc315437 100644 --- a/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts +++ b/src/vs/workbench/contrib/notebook/common/notebookEditorModel.ts @@ -85,6 +85,10 @@ export class SimpleNotebookEditorModel extends EditorModel implements INotebookE return this._workingCopy?.isDirty() ?? false; } + isModified(): boolean { + return this._workingCopy?.isModified() ?? false; + } + isOrphaned(): boolean { return SimpleNotebookEditorModel._isStoredFileWorkingCopy(this._workingCopy) && this._workingCopy.hasState(StoredFileWorkingCopyState.ORPHAN); } diff --git a/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts b/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts index c9f0a3114c7..095679ab6a0 100644 --- a/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts +++ b/src/vs/workbench/contrib/notebook/test/browser/testNotebookEditor.ts @@ -134,6 +134,10 @@ export class NotebookEditorTestModel extends EditorModel implements INotebookEdi return this._dirty; } + isModified(): boolean { + return this._dirty; + } + getNotebook(): NotebookTextModel { return this._notebook; }