diff --git a/.changeset/read-only-workspace-dirty.md b/.changeset/read-only-workspace-dirty.md new file mode 100644 index 00000000..9a925859 --- /dev/null +++ b/.changeset/read-only-workspace-dirty.md @@ -0,0 +1,5 @@ +--- +"@matdata/yasgui": patch +--- + +Queries opened from a read-only workspace are no longer marked as unsaved after edits, and closing their tab no longer asks to save. diff --git a/docs/user-guide.md b/docs/user-guide.md index a00d6a1e..3cbeab28 100644 --- a/docs/user-guide.md +++ b/docs/user-guide.md @@ -1034,6 +1034,7 @@ This feature is designed for **power users** who want to: - the workspace is never offered as a save target, and is marked "(read-only)" in the Query Browser - saving a query opened from it (`Ctrl+S`, the save button or the tab menu) opens **Save as**, so the changes can only be stored as a copy in another workspace - rename, move and delete are not available in the Query Browser, and renaming the tab only changes the tab label +- editing a query opened from it does not mark the tab as unsaved, and closing the tab does not ask to save When every configured workspace is read-only, the save button is hidden. diff --git a/packages/yasgui/src/Tab.ts b/packages/yasgui/src/Tab.ts index acd8b0be..c7924ea4 100644 --- a/packages/yasgui/src/Tab.ts +++ b/packages/yasgui/src/Tab.ts @@ -133,6 +133,8 @@ export class Tab extends EventEmitter { const meta = this.getManagedQueryMetadata(); if (!meta) return false; if (!meta.lastSavedTextHash) return false; + // Edits to a query from a read-only workspace can never be saved back, so they are not "unsaved changes". + if (isWorkspaceReadOnly(this.yasgui.persistentConfig.getWorkspace(meta.workspaceId))) return false; try { const current = this.yasqe ? this.yasqe.getValue() : this.persistentJson.yasqe.value;