提交 e09c8ef0 编写于 作者: R Rob Lourens

Fix #90981

上级 5e5fdffc
......@@ -123,8 +123,6 @@ export interface IConfigurationService {
workspaceFolder: string[];
memory?: string[];
};
getConfigurationFileResource(target: ConfigurationTarget, resource: URI | null | undefined): URI | null;
}
export interface IConfigurationModel {
......
......@@ -20,7 +20,7 @@ import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorE
import { Position } from 'vs/editor/common/core/position';
import { IModelDeltaDecoration, TrackedRangeStickiness } from 'vs/editor/common/model';
import { localize } from 'vs/nls';
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
import { IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IContextMenuService, IContextViewService } from 'vs/platform/contextview/browser/contextView';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
......@@ -32,7 +32,7 @@ import { ICssStyleCollector, IColorTheme, IThemeService, registerThemingParticip
import { IWorkspaceContextService, IWorkspaceFolder, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { PANEL_ACTIVE_TITLE_BORDER, PANEL_ACTIVE_TITLE_FOREGROUND, PANEL_INACTIVE_TITLE_FOREGROUND } from 'vs/workbench/common/theme';
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
import { ISettingsGroup } from 'vs/workbench/services/preferences/common/preferences';
import { ISettingsGroup, IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { isEqual } from 'vs/base/common/resources';
import { registerIcon, Codicon } from 'vs/base/common/codicons';
......@@ -311,7 +311,7 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem {
action: IAction,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IPreferencesService private readonly preferencesService: IPreferencesService,
) {
super(null, action);
const workspace = this.contextService.getWorkspace();
......@@ -401,14 +401,14 @@ export class FolderSettingsActionViewItem extends BaseActionViewItem {
}
}
private update(): void {
private async update(): Promise<void> {
let total = 0;
this._folderSettingCounts.forEach(n => total += n);
const workspace = this.contextService.getWorkspace();
if (this._folder) {
this.labelElement.textContent = this._folder.name;
this.anchorElement.title = this.configurationService.getConfigurationFileResource(ConfigurationTarget.WORKSPACE_FOLDER, this._folder.uri)?.fsPath || '';
this.anchorElement.title = (await this.preferencesService.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, this._folder.uri))?.fsPath || '';
const detailsText = this.labelWithCount(this._action.label, total);
this.detailsElement.textContent = detailsText;
DOM.toggleClass(this.dropDownElement, 'hide', workspace.folders.length === 1 || !this._action.checked);
......@@ -490,7 +490,7 @@ export class SettingsTargetsWidget extends Widget {
@IInstantiationService private readonly instantiationService: IInstantiationService,
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService,
@ILabelService private readonly labelService: ILabelService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IPreferencesService private readonly preferencesSerivce: IPreferencesService,
) {
super();
this.options = options || {};
......@@ -509,14 +509,19 @@ export class SettingsTargetsWidget extends Widget {
}));
this.userLocalSettings = new Action('userSettings', localize('userSettings', "User"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER_LOCAL));
this.userLocalSettings.tooltip = this.configurationService.getConfigurationFileResource(ConfigurationTarget.USER_LOCAL, undefined)?.fsPath || '';
this.preferencesSerivce.getEditableSettingsURI(ConfigurationTarget.USER_LOCAL).then(uri => {
// Don't wait to create UI on resolving remote
this.userLocalSettings.tooltip = uri?.fsPath || '';
});
const remoteAuthority = this.environmentService.configuration.remoteAuthority;
const hostLabel = remoteAuthority && this.labelService.getHostLabel(REMOTE_HOST_SCHEME, remoteAuthority);
const remoteSettingsLabel = localize('userSettingsRemote', "Remote") +
(hostLabel ? ` [${hostLabel}]` : '');
this.userRemoteSettings = new Action('userSettingsRemote', remoteSettingsLabel, '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER_REMOTE));
this.userRemoteSettings.tooltip = this.configurationService.getConfigurationFileResource(ConfigurationTarget.USER_REMOTE, undefined)?.fsPath || '';
this.preferencesSerivce.getEditableSettingsURI(ConfigurationTarget.USER_REMOTE).then(uri => {
this.userRemoteSettings.tooltip = uri?.fsPath || '';
});
this.workspaceSettings = new Action('workspaceSettings', localize('workspaceSettings', "Workspace"), '.settings-tab', false, () => this.updateTarget(ConfigurationTarget.WORKSPACE));
......@@ -588,15 +593,14 @@ export class SettingsTargetsWidget extends Widget {
return Promise.resolve(undefined);
}
private update(): void {
private async update(): Promise<void> {
DOM.toggleClass(this.settingsSwitcherBar.domNode, 'empty-workbench', this.contextService.getWorkbenchState() === WorkbenchState.EMPTY);
this.userRemoteSettings.enabled = !!(this.options.enableRemoteSettings && this.environmentService.configuration.remoteAuthority);
this.workspaceSettings.enabled = this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY;
this.folderSettings.getAction().enabled = this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE && this.contextService.getWorkspace().folders.length > 0;
this.workspaceSettings.tooltip = this.configurationService.getConfigurationFileResource(ConfigurationTarget.WORKSPACE, undefined)?.fsPath || '';
this.workspaceSettings.tooltip = (await this.preferencesSerivce.getEditableSettingsURI(ConfigurationTarget.WORKSPACE))?.fsPath || '';
}
}
export interface SearchOptions extends IInputOptions {
......
......@@ -14,7 +14,7 @@ import { IWorkspaceContextService, Workspace, WorkbenchState, IWorkspaceFolder,
import { ConfigurationModel, DefaultConfigurationModel, ConfigurationChangeEvent, AllKeysConfigurationChangeEvent, mergeChanges } from 'vs/platform/configuration/common/configurationModels';
import { IConfigurationChangeEvent, ConfigurationTarget, IConfigurationOverrides, keyFromOverrideIdentifier, isConfigurationOverrides, IConfigurationData, IConfigurationService, IConfigurationValue, IConfigurationChange } from 'vs/platform/configuration/common/configuration';
import { Configuration } from 'vs/workbench/services/configuration/common/configurationModels';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES, FOLDER_SETTINGS_PATH } from 'vs/workbench/services/configuration/common/configuration';
import { FOLDER_CONFIG_FOLDER_NAME, defaultSettingsSchemaId, userSettingsSchemaId, workspaceSettingsSchemaId, folderSettingsSchemaId, IConfigurationCache, machineSettingsSchemaId, LOCAL_MACHINE_SCOPES } from 'vs/workbench/services/configuration/common/configuration';
import { Registry } from 'vs/platform/registry/common/platform';
import { IConfigurationRegistry, Extensions, allSettings, windowSettings, resourceSettings, applicationSettings, machineSettings, machineOverridableSettings } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkspaceIdentifier, isWorkspaceIdentifier, IStoredWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier, IWorkspaceInitializationPayload, isSingleFolderWorkspaceInitializationPayload, ISingleFolderWorkspaceInitializationPayload, IEmptyWorkspaceInitializationPayload, useSlashForPath, getStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces';
......@@ -310,23 +310,6 @@ export class WorkspaceService extends Disposable implements IConfigurationServic
}
}
public getConfigurationFileResource(target: ConfigurationTarget, resource: URI | null | undefined): URI | null {
let editableTarget: EditableConfigurationTarget;
if (target === ConfigurationTarget.USER || target === ConfigurationTarget.USER_LOCAL) {
editableTarget = EditableConfigurationTarget.USER_LOCAL;
} else if (target === ConfigurationTarget.USER_REMOTE) {
editableTarget = EditableConfigurationTarget.USER_REMOTE;
} else if (target === ConfigurationTarget.WORKSPACE) {
editableTarget = EditableConfigurationTarget.WORKSPACE;
} else if (target === ConfigurationTarget.WORKSPACE_FOLDER) {
editableTarget = EditableConfigurationTarget.WORKSPACE_FOLDER;
} else {
return null;
}
return this.configurationEditingService?.getConfigurationFileResource(editableTarget, FOLDER_SETTINGS_PATH, resource);
}
private createWorkspace(arg: IWorkspaceInitializationPayload): Promise<Workspace> {
if (isWorkspaceIdentifier(arg)) {
return this.createMultiFolderWorkspace(arg);
......
......@@ -578,7 +578,7 @@ export class ConfigurationEditingService {
return !!(workspace.configuration && resource && workspace.configuration.fsPath === resource.fsPath);
}
public getConfigurationFileResource(target: EditableConfigurationTarget, relativePath: string, resource: URI | null | undefined): URI | null {
private getConfigurationFileResource(target: EditableConfigurationTarget, relativePath: string, resource: URI | null | undefined): URI | null {
if (target === EditableConfigurationTarget.USER_LOCAL) {
if (relativePath) {
return resources.joinPath(resources.dirname(this.environmentService.settingsResource), relativePath);
......
......@@ -518,7 +518,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return this._defaultUserSettingsContentModel;
}
private async getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise<URI | null> {
public async getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise<URI | null> {
switch (configurationTarget) {
case ConfigurationTarget.USER:
case ConfigurationTarget.USER_LOCAL:
......
......@@ -207,6 +207,7 @@ export interface IPreferencesService {
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Promise<void>;
openGlobalKeybindingSettings(textual: boolean): Promise<void>;
openDefaultKeybindingsFile(): Promise<IEditorPane | undefined>;
getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): Promise<URI | null>;
}
export function getSettingsTargetName(target: ConfigurationTarget, resource: URI, workspaceContextService: IWorkspaceContextService): string {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册