-
Notifications
You must be signed in to change notification settings - Fork 29.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
create a scratchpad untitled workingcopy for the IW model #181280
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I like the direction of the new capability and how it can be applied via the manager. But applying the capability needs to be done with care in all locations: sometimes we use the onDidChangeDirty
event to update an indicator but then sometimes we use the dirtyCount
or dirtyWorkingCopies
or hasDirty
. Since we are not disabling the dirty state for scratchpad working copies (which I think is good so that backups are triggered) we probably have to jump into each location and figure out how to treat scratchpad working copies...
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.ts
Outdated
Show resolved
Hide resolved
I went through each usage of the
|
I'm also up for adding some tests - it looks like the |
@amunger I did a pass over every use of dirty state tracking for working copies and I am now even more convinced that the best way forward is to exclude scratchpad working copies from dirty tracking entirely, meaning:
As soon as we do that, scrapbook working copies will not cause dirty indicators to appear, nor confirmation dialogs to appear, nor will any of the save actions trigger a save. However, there are a few locations where we explicitly have to account for scrapbooks that have content. Here are the ones I found: Editor Group View Editor Observer Working Copy Backup Tracker
For that we need something new that is not "dirty" but signals the intent. I am open for suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did a quick review
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopy.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.ts
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/common/untitledFileWorkingCopyManager.ts
Outdated
Show resolved
Hide resolved
…ngCopy.ts Co-authored-by: Benjamin Pasero <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like all the changes but think we now need to focus on backup tracker. I am not convinced we have all the changes yet to ensure backups are present, including shutdown.
Backup tracker makes extensive use of tracking "dirty" working copies. Scratchpad working copies are never dirty. You schedule a backup in onDidChangeContent
which is important, but there are other places that are not tracked. Can you make a pass and see what to do? I think we will have to introduce a new field on the working copy service and maybe on the working copy itself to signal back that content has changed in the past and that a backup should be done.
I think you only need to check all the (3?) workingCopyBackupTracker.ts
files for this.
oof, yes I missed that since the IW does it's own backup at the moment (hopefully can integrate as a next step) common web electron-sandbox |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like the term "modified" to signal backups are needed for a working copy. But then we should also make sure that when we have a comment, we refer to "modified" as term and not "dirty" or "unsaved changes". Makes it easier to understand the code imho 👍
I left lots of little review comments but on a high level think that you missed some cases where a modified working copy without backup should still block the shutdown from happening. If a user has a modified scrapbook and hot exit is disabled we still need to show a dialog, to not loose user data.
Overall I think we are getting close to done.
src/vs/workbench/services/textmodelResolver/test/browser/textModelResolverService.test.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/untitled/common/untitledTextEditorModel.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts
Outdated
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts
Show resolved
Hide resolved
src/vs/workbench/services/workingCopy/electron-sandbox/workingCopyBackupTracker.ts
Outdated
Show resolved
Hide resolved
With the change to block shutdown for modified scratchpads, I had to remove the IWs implementation since we need to think more about what 'save' will do for an IW if we're going to force users to take that action. |
src/vs/workbench/services/workingCopy/test/browser/untitledScratchpadWorkingCopy.test.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Getting there 👍
Can you search for dirty
in src/vs/workbench/services/workingCopy/common/workingCopyBackupTracker.ts
and review where we still need to deal with modified and not dirty, I think its not done yet.
I would expect that I can save a scratchpad when I do this explicitly and it would open a dialog asking where to save to, similar to untitled files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is good to go. I spend some time thinking about 2 somewhat loose ends that are slightly off:
- do we need a
onDidChangeModified
event given we have introducedmodified
as a concept? or should we maybe rename the existingonDidChangeContent
? Should we drop content-change notion and only use modified? - if you search for
markDirty
in our sources you find a way for clients to mark a untitled working copy as dirty. should this be renamed tomarkModified
or is the correct term as it is now?
I am not sure these 2 bullets warrant for blocking this PR any l longer though, thus approving.
for #174485