mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Hide machine-scoped settings from User tab in remote window
Fix microsoft/vscode-remote-release#2
This commit is contained in:
parent
36ba1d3ea8
commit
0a7ec36603
|
@ -45,6 +45,7 @@ import { ISettingsEditorViewState, settingKeyToDisplayFormat, SettingsTreeElemen
|
|||
import { ExcludeSettingWidget, IExcludeChangeEvent, IExcludeDataItem, settingsHeaderForeground, settingsNumberInputBackground, settingsNumberInputBorder, settingsNumberInputForeground, settingsSelectBackground, settingsSelectBorder, settingsSelectForeground, settingsSelectListBorder, settingsTextInputBackground, settingsTextInputBorder, settingsTextInputForeground } from 'vs/workbench/contrib/preferences/browser/settingsWidgets';
|
||||
import { SETTINGS_EDITOR_COMMAND_SHOW_CONTEXT_MENU } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { ISetting, ISettingsGroup, SettingValueType } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
const $ = DOM.$;
|
||||
|
||||
|
@ -1163,6 +1164,7 @@ function escapeInvisibleChars(enumValue: string): string {
|
|||
export class SettingsTreeFilter implements ITreeFilter<SettingsTreeElement> {
|
||||
constructor(
|
||||
private viewState: ISettingsEditorViewState,
|
||||
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
|
||||
) { }
|
||||
|
||||
filter(element: SettingsTreeElement, parentVisibility: TreeVisibility): TreeFilterResult<void> {
|
||||
|
@ -1175,7 +1177,8 @@ export class SettingsTreeFilter implements ITreeFilter<SettingsTreeElement> {
|
|||
|
||||
// Non-user scope selected
|
||||
if (element instanceof SettingsTreeSettingElement && this.viewState.settingsTarget !== ConfigurationTarget.USER_LOCAL) {
|
||||
if (!element.matchesScope(this.viewState.settingsTarget)) {
|
||||
const isRemote = !!this.environmentService.configuration.remoteAuthority;
|
||||
if (!element.matchesScope(this.viewState.settingsTarget, isRemote)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -1303,7 +1306,8 @@ export class SettingsTree extends ObjectTree<SettingsTreeElement> {
|
|||
container: HTMLElement,
|
||||
viewState: ISettingsEditorViewState,
|
||||
renderers: ITreeRenderer<any, void, any>[],
|
||||
@IThemeService themeService: IThemeService
|
||||
@IThemeService themeService: IThemeService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
) {
|
||||
const treeClass = 'settings-editor-tree';
|
||||
|
||||
|
@ -1320,7 +1324,7 @@ export class SettingsTree extends ObjectTree<SettingsTreeElement> {
|
|||
}
|
||||
},
|
||||
styleController: new DefaultStyleController(DOM.createStyleSheet(container), treeClass),
|
||||
filter: new SettingsTreeFilter(viewState)
|
||||
filter: instantiationService.createInstance(SettingsTreeFilter, viewState)
|
||||
});
|
||||
|
||||
this.disposables = [];
|
||||
|
|
|
@ -14,6 +14,7 @@ import { SettingsTarget } from 'vs/workbench/contrib/preferences/browser/prefere
|
|||
import { ITOCEntry, knownAcronyms, knownTermMappings } from 'vs/workbench/contrib/preferences/browser/settingsLayout';
|
||||
import { MODIFIED_SETTING_TAG } from 'vs/workbench/contrib/preferences/common/preferences';
|
||||
import { IExtensionSetting, ISearchResult, ISetting, SettingValueType } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
export const ONLINE_SERVICES_SETTING_TAG = 'usesOnlineServices';
|
||||
|
||||
|
@ -221,7 +222,7 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
|
|||
}
|
||||
}
|
||||
|
||||
matchesScope(scope: SettingsTarget): boolean {
|
||||
matchesScope(scope: SettingsTarget, isRemote: boolean): boolean {
|
||||
const configTarget = URI.isUri(scope) ? ConfigurationTarget.WORKSPACE_FOLDER : scope;
|
||||
|
||||
if (configTarget === ConfigurationTarget.WORKSPACE_FOLDER) {
|
||||
|
@ -236,6 +237,10 @@ export class SettingsTreeSettingElement extends SettingsTreeElement {
|
|||
return this.setting.scope === ConfigurationScope.MACHINE || this.setting.scope === ConfigurationScope.WINDOW || this.setting.scope === ConfigurationScope.RESOURCE;
|
||||
}
|
||||
|
||||
if (configTarget === ConfigurationTarget.USER_LOCAL && isRemote) {
|
||||
return this.setting.scope !== ConfigurationScope.MACHINE;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -479,7 +484,8 @@ export class SearchResultModel extends SettingsTreeModel {
|
|||
|
||||
constructor(
|
||||
viewState: ISettingsEditorViewState,
|
||||
@IConfigurationService configurationService: IConfigurationService
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService,
|
||||
) {
|
||||
super(viewState, configurationService);
|
||||
this.update({ id: 'searchResultModel', label: '' });
|
||||
|
@ -537,8 +543,9 @@ export class SearchResultModel extends SettingsTreeModel {
|
|||
});
|
||||
|
||||
// Save time, filter children in the search model instead of relying on the tree filter, which still requires heights to be calculated.
|
||||
const isRemote = !!this.environmentService.configuration.remoteAuthority;
|
||||
this.root.children = this.root.children
|
||||
.filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget) && child.matchesAnyExtension(this._viewState.extensionFilters));
|
||||
.filter(child => child instanceof SettingsTreeSettingElement && child.matchesAllTags(this._viewState.tagFilters) && child.matchesScope(this._viewState.settingsTarget, isRemote) && child.matchesAnyExtension(this._viewState.extensionFilters));
|
||||
|
||||
if (this.newExtensionSearchResults && this.newExtensionSearchResults.filterMatches.length) {
|
||||
const newExtElement = new SettingsTreeNewExtensionsElement();
|
||||
|
|
|
@ -17,6 +17,7 @@ import { SettingsTreeFilter } from 'vs/workbench/contrib/preferences/browser/set
|
|||
import { ISettingsEditorViewState, SearchResultModel, SettingsTreeElement, SettingsTreeGroupElement, SettingsTreeSettingElement } from 'vs/workbench/contrib/preferences/browser/settingsTreeModels';
|
||||
import { settingsHeaderForeground } from 'vs/workbench/contrib/preferences/browser/settingsWidgets';
|
||||
import { localize } from 'vs/nls';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
||||
const $ = DOM.$;
|
||||
|
||||
|
@ -25,7 +26,10 @@ export class TOCTreeModel {
|
|||
private _currentSearchModel: SearchResultModel | null;
|
||||
private _settingsTreeRoot: SettingsTreeGroupElement;
|
||||
|
||||
constructor(private _viewState: ISettingsEditorViewState) {
|
||||
constructor(
|
||||
private _viewState: ISettingsEditorViewState,
|
||||
@IWorkbenchEnvironmentService private environmentService: IWorkbenchEnvironmentService
|
||||
) {
|
||||
}
|
||||
|
||||
get settingsTreeRoot(): SettingsTreeGroupElement {
|
||||
|
@ -81,7 +85,8 @@ export class TOCTreeModel {
|
|||
}
|
||||
|
||||
// Check everything that the SettingsFilter checks except whether it's filtered by a category
|
||||
return child.matchesScope(this._viewState.settingsTarget) && child.matchesAllTags(this._viewState.tagFilters) && child.matchesAnyExtension(this._viewState.extensionFilters);
|
||||
const isRemote = !!this.environmentService.configuration.remoteAuthority;
|
||||
return child.matchesScope(this._viewState.settingsTarget, isRemote) && child.matchesAllTags(this._viewState.tagFilters) && child.matchesAnyExtension(this._viewState.extensionFilters);
|
||||
}).length;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -557,7 +557,7 @@ export class SettingsEditor2 extends BaseEditor {
|
|||
}
|
||||
|
||||
private createTOC(parent: HTMLElement): void {
|
||||
this.tocTreeModel = new TOCTreeModel(this.viewState);
|
||||
this.tocTreeModel = this.instantiationService.createInstance(TOCTreeModel, this.viewState);
|
||||
this.tocTreeContainer = DOM.append(parent, $('.settings-toc-container'));
|
||||
|
||||
this.tocTree = this._register(this.instantiationService.createInstance(TOCTree,
|
||||
|
|
Loading…
Reference in a new issue