Skip to content

Warn about unsaved query changes, and mark modified tabs #462

Description

@erikdarlingdata

Reported by @joshdbe in #458 after testing the new Open/Save Query.

A query session has no idea whether it has been edited. You can open a .sql, change it, close the tab or the app, and lose the edit without being asked. Nothing anywhere warns you.

Two symptoms, one missing piece:

  1. No prompt on close. Closing a modified tab, or the window, discards the edit silently. Wanted: Save / Don't Save / Cancel, and Cancel actually cancels the close.
  2. No modified marker. Josh asked for the VS Code treatment — the tab's × becomes a filled dot while there are unsaved changes, and goes back to × on hover so you can still close it.

What's there now

QuerySessionControl gained SourceFilePath in #459 but tracks nothing about content. The dirty flag is the whole feature; both symptoms are consumers of it.

  • Compare QueryEditor.Text against the text as of the last load or save, rather than a bare "was edited" bool — retyping something back to how it started should not leave the tab marked.
  • A never-saved scratch tab with content typed into it is also dirty, and its prompt has to go through Save As, not save-in-place.
  • The tab header is StackPanel { headerText, closeBtn } in MainWindow.Tabs.cs, so the marker is a swap of closeBtn content plus a pointer-over trigger.
  • Window.Closing needs to walk every tab, not just the active one, and cancel the close if anyone picks Cancel.

Plan tabs are read-only and are not part of this.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions