-
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
preferences: fix duplicated resolution #12165
Conversation
The `WorkspacePreferenceProvider` can do one of two things: It may return preferences from the current workspace folder if the workspace is a single root workspace, or it may return preferences as defined in the workspace file if the workspace is a multi-root workspace. Whenever we want to resolve a preference, the following scopes are queried: `Default`, `User`, `Workspace`, and `Folder`. When a single root workspace is opened the following happens: - Query `Default` scope [...] - Query `User` scope [...] - Query `Workspace` scope: use `WorkspacePreferenceProvider` which delegates to `FolderPreferenceProvider`. - Query `Folder` scope: use `FoldersPreferenceProvider`. Conclusion: The `FoldersPreferenceProvider` is queried twice. In order to fix that issue this commit introduces a new component: `TogglePreferenceProvider` which extends `PreferenceProvider` and wraps another provider so that it can be enabled/disabled. Whenever we are running a single root workspace, we'll enable the `FoldersPreferenceProvider` used by `WorkspacePreferenceProvider` and disable the one bound to the `Folder` scope. Whenever we are running a multi root workspace, we'll disable the `FoldersPreferenceProvider` used by `WorkspacePreferenceProvider` and enable the one bound to the `Folder` scope.
I didn't know what to do with our current preference infrastructure. It's a mess, and this patch doesn't make things really nicer... In the meantime, this patch seems to work (on my machine) and it's not super invasive. If anyone has a better idea please open an alternative PR, or push directly to this one if you can. |
I also found a bug in the PreferenceProvider while investigating this issue: the merge of array values was producing duplicates. I pushed my changes here eclipsesource@eb8d246 With my changes alone, some tests from |
@paul-marechal I saw that this PR impacts the Playwright page objects. On a first glance, it looks like the selector of the modification indicator in the gutter needs to be adapted. Please let me know if you'd like us to assist with that. |
Since the `PreferenceProvider` for the `Folder` is now completely disabled when in a single root workspace, we need to update clients that were relying on it.
@AlexandraBuzila my problem is that from the code alone: theia/packages/core/src/browser/preferences/preference-provider.ts Lines 225 to 246 in 371ab02
I can't see why values would be duplicated, unless we pass two arrays containing the same data together. If you read the PR description I highlighted the root cause of the duplication: that is the preference system calls twice the same handler. Since the previous logic didn't properly merge arrays, that didn't seem to cause an issue before. With that in mind, this PR addresses this problem of |
@planger I don't think this PR should require updating Playwright object models, let me see if I can fix the issues that appeared in CI first. |
Closing in favor of #12174 |
The
WorkspacePreferenceProvider
can do one of two things: It may return preferences from the current workspace folder if the workspace is a single root workspace, or it may return preferences as defined in the workspace file if the workspace is a multi-root workspace.Whenever we want to resolve a preference, the following scopes are queried:
Default
,User
,Workspace
, andFolder
.When a single root workspace is opened the following happens:
Default
scope [...]User
scope [...]Workspace
scope: useWorkspacePreferenceProvider
which delegates toFoldersPreferenceProvider
.Folder
scope: useFoldersPreferenceProvider
.Conclusion: The
FoldersPreferenceProvider
is queried twice.In order to fix that issue this commit introduces a new component:
TogglePreferenceProvider
which extendsPreferenceProvider
and wraps another provider so that it can be enabled/disabled.Whenever we are running a single root workspace, we'll enable the
FoldersPreferenceProvider
used byWorkspacePreferenceProvider
and disable the one bound to theFolder
scope.Whenever we are running a multi root workspace, we'll disable the
FoldersPreferenceProvider
used byWorkspacePreferenceProvider
and enable the one bound to theFolder
scope.Fixes #12153
How to test
See instructions in #12153
Review checklist
Reminder for reviewers