Replace any active untitled untouched document on Open#257
Merged
Conversation
lhecker
reviewed
May 24, 2025
src/bin/edit/documents.rs
Outdated
| }; | ||
| doc.set_path(path); | ||
|
|
||
| if self.list.len() == 1 |
Member
There was a problem hiding this comment.
I think we can skip the .len() check and just unconditionally check the most recent document. We could theoretically go even one step further and find any document that fulfills the condition... but maybe that's a step too for a first test.
This may be a controversial opinion. It felt weird to open edit, open a file, and then see "FILE + 1". I didn't care about the empty Untitled document, and there was no reason for it to be kept around. After this pull request, if you launch edit and then Open a new document without editing the existing placeholder untitled document or giving it a name, Edit will close that document and open the new one. This only applies if there is a single untitled document. If there are other documents open, we won't close any untitled documents. We could conceivably expand this behavior to replace *any* untouched untitled document when you Open a new one.
c69f37f to
0de1c4a
Compare
lhecker
approved these changes
May 27, 2025
Lou32Verbose
pushed a commit
to Lou32Verbose/edit
that referenced
this pull request
Jan 11, 2026
This may be a controversial opinion. It felt weird to open edit, open a file, and then see "FILE + 1". I didn't care about the empty Untitled document, and there was no reason for it to be kept around. After this pull request, if you launch edit and then Open a new document without editing the existing placeholder untitled document or giving it a name, Edit will close that document and open the new one. The same applies to New: if you press New, and then Open, Edit will close the untitled temporary document.
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.
This may be a controversial opinion.
It felt weird to open edit, open a file, and then see "FILE + 1". I
didn't care about the empty Untitled document, and there was no reason
for it to be kept around.
After this pull request, if you launch edit and then Open a new document
without editing the existing placeholder untitled document or giving it
a name, Edit will close that document and open the new one.
The same applies to New: if you press New, and then Open, Edit will close the untitled temporary document.