Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/read-only-workspace-dirty.md
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions docs/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
2 changes: 2 additions & 0 deletions packages/yasgui/src/Tab.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Loading