feat(save): Opening a non-existent file should not trigger "save file" - #335956
Closed
tlimoncelli26 wants to merge 1 commit into
Closed
feat(save): Opening a non-existent file should not trigger "save file"#335956tlimoncelli26 wants to merge 1 commit into
tlimoncelli26 wants to merge 1 commit into
Conversation
Contributor
There was a problem hiding this comment.
🟢 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #327076
Add a setting
workbench.editor.untitled.dirtyWhenEmptythat 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.dirtyWhenEmptyretains the current behavior. The setting must be disabled to get the new behavior.