Skip to content

feat(save): Opening a non-existent file should not trigger "save file" - #335956

Closed
tlimoncelli26 wants to merge 1 commit into
microsoft:mainfrom
tlimoncelli26:tlimoncelli26/b327076/attempt1
Closed

feat(save): Opening a non-existent file should not trigger "save file"#335956
tlimoncelli26 wants to merge 1 commit into
microsoft:mainfrom
tlimoncelli26:tlimoncelli26/b327076/attempt1

Conversation

@tlimoncelli26

Copy link
Copy Markdown

Fixes #327076

Add a setting workbench.editor.untitled.dirtyWhenEmpty that prevents a newly created, empty and untouched file from being treated as "dirty," so that closing it does not trigger a "Do you want to save?" prompt.

In Microsoft VSCode, if you open a new file ("code doesnotexist.txt` from the Terminal), make no changes, then try to exit, it asks if you want to save the file. Other editors, such as Vim and Emacs, do not ask to save the file. This feature gives users the option to emulate that behavior.

The default setting for workbench.editor.untitled.dirtyWhenEmpty retains the current behavior. The setting must be disabled to get the new behavior.

Copilot AI balanced review requested due to automatic review settings September 12, 2026 13:02

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation is localized, preserves the default behavior, and includes adequate coverage for relevant edge cases.

Pull request overview

Adds an opt-in setting to avoid marking empty, path-associated untitled files as dirty.

Changes:

  • Registers workbench.editor.untitled.dirtyWhenEmpty, defaulting to current behavior.
  • Updates dirty-state handling while preserving initial-content and backup behavior.
  • Adds focused tests for enabled, disabled, initial-content, and backup scenarios.
File summaries
File Description
src/vs/workbench/browser/workbench.contribution.ts Registers and documents the setting.
src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts Applies the setting to dirty-state tracking.
src/vs/workbench/services/untitled/test/browser/untitledTextEditor.test.ts Covers the new behavior and safeguards.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Opening a non-existent file should not trigger "save dirty file" (Vim/Emacs-style "nothing changed, nothing to save")

2 participants