The preference scope problem

hi! I just want my preference only shows in the folder preference,
so I added scope: PreferenceScope.Folder,but it also shows in the workspace folderUploading: image.png… ,how can I do to make my preference only show in the workspace preference or in the folder preference

Hello @connor, at the moment, the way the preferences system is designed is that any preference available in a narrow scope (e.g. folder) is also available in a higher scope (e.g. user). The reasoning behind that is that it makes sense to allow a user to configure default global behavior for almost every preference, but only some preferences make sense to be configured at workspace or folder levels. The places where this logic is enforced are here:

Where we update the schema for different scopes: folder only for folder-scoped preferences, workspace for folder-scoped and workspace-scoped preferences, and user scope for everything.

And here:

Where we determine whether a preference is valid in a given scope. The logic to handle language-overridable preferences muddies the waters a bit, but basically it’s a simple comparison of whether the scope is <= or equal to the scope specified for the preference. That means that anything valid in folder scope is valid in workspace and user scopes, anything valid in workspace is valid in user, and anything listed for user scope is only valid in user scope.

If you’d like to try to modify that behavior yourself, you can override the PreferenceSchemaProvider in your application to implement the logic you’re interested in; and if you think the current logic should be improved, please feel free to make an issue or start a PR on the Theia project.

If you think your use case is of general interest, we would like hear more about why you need your preference just in folder scope.

Yes,we have folder project to set project preference like project name and so on

Since this “works as designed” I would suggest that you file an enhancement request with a case supporting the feature. Maybe one of the contributors will pick it up, but since this hasn’t come up as a requirement so far, it might end up as “help wanted”.