-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Handle open preference files #7775
Handle open preference files #7775
Conversation
3fd26f1
to
67455ff
Compare
67455ff
to
79c4ff2
Compare
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.
Functionally the changes work really well 👍
I verified the following:
- making preference updates through the UI saves the document
- making preference updates through the UI with a dirty document results in a prompt
- the prompt option 'save and retry' successfully saves the document and reapplies the update
- the prompt option 'open file' opens the document
I don't have any objections with the code, I'll however give others a chance to review as well
packages/preferences/src/browser/abstract-resource-preference-provider.ts
Outdated
Show resolved
Hide resolved
We should test how it work without editors. When Theia/VS Code extensions do concurrent updates. It would be good to provide sample VS Code extension to verify it. It should not cause any notifications or unnecessary save cycles. |
79c4ff2
to
363f176
Compare
@akosyakov, I have finally gotten around to writing tests for this PR, and in the process, I have changed the code quite a bit. Basically, I have implemented a queue mechanism for calls to the
With the queue mechanism I've implemented, the behavior is the same regardless of whether an editor is open or not (assuming the editor is not dirty):
This means that any number of concurrent calls result in only one save cycle, whether the editor is dirty or not. If the editor is dirty:
I have added tests to the |
363f176
to
556b151
Compare
@vince-fugnitto, I've rebased this PR and run tests locally (and now they've finished in CI - not sure why Ubuntu + Python 2 doesn't like me). It comes in two forms:
The fact of the matter is that the current code generates tons of save cycles if the file is not open, so it doesn't make very much sense to me to quibble about doing the same when the file is open. But, if it's desirable to reduce the number of saves when the system is under pressure, what I've implemented is a move in that direction, and I'm happy to work on improving it if anyone has suggestions on how it can be made better. |
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.
@colin-grant-work do you mind rebasing the pull-request (there were recent significant changes to the preferences). I can review afterwards 👍
556b151
to
9217fcc
Compare
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.
@colin-grant-work I don't have any objections to the approach taken by the pull-request, if you are to rebase it should fix the failing api-tests
👍
I've asked that @marechal-p also take a look, namely how we handle queued preference changes.
9217fcc
to
aae4e0c
Compare
aae4e0c
to
f36030c
Compare
f36030c
to
99db729
Compare
@vince-fugnitto, @paul-marechal, with the addition of |
07e5a39
to
790bb87
Compare
545ef97
to
2dc7add
Compare
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 was able to disconnect the UI from the settings editor. Afterwards, any changes made to the UI or the settings file are not reflected in the other one:
- Update a preference in the UI.
- Open the settings.json file.
- Change the preference file, but don't save it.
- Change the value again in the UI, and click on the "Open file" action in the resulting notification (at this point the UI and file editor are disconnected)
- Change the value in the settings json, save it
- The change is not reflected in the UI
The "save and retry" and cancel actions work perfectly fine though.
@msujew, thanks for the test. Older versions of this PR - before |
425b1e8
to
3acdbba
Compare
@msujew, I've brought back / reimplemented the UI reversion behavior, and added another step to the testing to confirm that even multiple changes to the UI while the toast is up will all be reverted. |
3acdbba
to
e8b6123
Compare
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 confirmed that the following work well:
- #7721 is fixed
- #9115 is fixed
- #2547 is fixed
- confirmed that setting preferences with existing errors in the
settings.json
works - confirmed that settings preferences with a dirty
settings.json
will prompt users to cancel, open the file, or save and retry - all actions work well - confirmed that saving a dirty
settings.json
file will update the UI properly - confirmed the behavior on all available scopes - user, workspace, folder (multi-root)
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.
The changes look good to me as well 👍
- Changes to preferences in the UI or the respective settings.json file are updated immediately in the other
- The actions when the settings file contains unsaved changes all work as expected
- Works correctly for all preference scopes
Signed-off-by: Colin Grant <[email protected]>
Signed-off-by: Colin Grant <[email protected]>
…le provider Signed-off-by: Colin Grant <[email protected]>
Signed-off-by: Colin Grant <[email protected]>
Signed-off-by: Colin Grant <[email protected]>
Signed-off-by: Colin Grant <[email protected]>
1f7c7e1
to
fc83147
Compare
fc83147
to
713e44e
Compare
Signed-off-by: Colin Grant [email protected]
What it does
This PR moves the preference UI in the direction of VSCode in two respects:
It fixes Preference changes not registered when
settings.json
open in editor. #7721 by saving the preference file when an edit is made.It fixes Setting two preferences synchronously creates both
.vscode
and.theia
folders. #9115 by processing preference settings in sequence.It fixes Cannot add a value via the preference widget #2547 by prompting the user when the settings file can't be modified.
It changes the behavior of the
AbstractPreferenceProvider.set
method to ensure that no changes are made to a file when that file is open in a dirty editor. Instead, an error toast is shown.It improves the UI further by resetting the UI to the pre-change-attempt state if a preference change attempt fails.
How to test
{}
in upper right)application.confirmExit
as the sole test case)Review checklist
Reminder for reviewers