mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Vscode merge (#4582)
* Merge from vscode 37cb23d3dd4f9433d56d4ba5ea3203580719a0bd * fix issues with merges * bump node version in azpipe * replace license headers * remove duplicate launch task * fix build errors * fix build errors * fix tslint issues * working through package and linux build issues * more work * wip * fix packaged builds * working through linux build errors * wip * wip * wip * fix mac and linux file limits * iterate linux pipeline * disable editor typing * revert series to parallel * remove optimize vscode from linux * fix linting issues * revert testing change * add work round for new node * readd packaging for extensions * fix issue with angular not resolving decorator dependencies
This commit is contained in:
@@ -18,7 +18,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import * as nls from 'vs/nls';
|
||||
import { ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { ConfigurationTarget, IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { FileOperationError, FileOperationResult, IFileService } from 'vs/platform/files/common/files';
|
||||
@@ -29,13 +29,13 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { EditorInput, IEditor } from 'vs/workbench/common/editor';
|
||||
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
|
||||
import { IJSONEditingService } from 'vs/workbench/services/configuration/common/jsonEditing';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { GroupDirection, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/group/common/editorGroupsService';
|
||||
import { GroupDirection, IEditorGroup, IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { DEFAULT_SETTINGS_EDITOR_SETTING, FOLDER_SETTINGS_PATH, getSettingsTargetName, IPreferencesEditorModel, IPreferencesService, ISetting, ISettingsEditorOptions, SettingsEditorOptions, USE_SPLIT_JSON_SETTING } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { DefaultPreferencesEditorInput, KeybindingsEditorInput, PreferencesEditorInput, SettingsEditor2Input } from 'vs/workbench/services/preferences/common/preferencesEditorInput';
|
||||
import { defaultKeybindingsContents, DefaultKeybindingsEditorModel, DefaultSettings, DefaultSettingsEditorModel, Settings2EditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
|
||||
import { defaultKeybindingsContents, DefaultKeybindingsEditorModel, DefaultSettings, DefaultSettingsEditorModel, Settings2EditorModel, SettingsEditorModel, WorkspaceConfigurationEditorModel, DefaultRawSettingsEditorModel } from 'vs/workbench/services/preferences/common/preferencesModels';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
|
||||
const emptyEditableSettingsContent = '{\n}';
|
||||
|
||||
@@ -45,7 +45,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
|
||||
private lastOpenedSettingsInput: PreferencesEditorInput | null = null;
|
||||
|
||||
private readonly _onDispose = new Emitter<void>();
|
||||
private readonly _onDispose = this._register(new Emitter<void>());
|
||||
|
||||
private _defaultUserSettingsUriCounter = 0;
|
||||
private _defaultUserSettingsContentModel: DefaultSettings;
|
||||
@@ -58,7 +58,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IWorkspaceConfigurationService private readonly configurationService: IWorkspaceConfigurationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@INotificationService private readonly notificationService: INotificationService,
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IInstantiationService private readonly instantiationService: IInstantiationService,
|
||||
@@ -74,24 +74,24 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
super();
|
||||
// The default keybindings.json updates based on keyboard layouts, so here we make sure
|
||||
// if a model has been given out we update it accordingly.
|
||||
keybindingService.onDidUpdateKeybindings(() => {
|
||||
this._register(keybindingService.onDidUpdateKeybindings(() => {
|
||||
const model = modelService.getModel(this.defaultKeybindingsResource);
|
||||
if (!model) {
|
||||
// model has not been given out => nothing to do
|
||||
return;
|
||||
}
|
||||
modelService.updateModel(model, defaultKeybindingsContents(keybindingService));
|
||||
});
|
||||
}));
|
||||
}
|
||||
|
||||
readonly defaultKeybindingsResource = URI.from({ scheme: network.Schemas.vscode, authority: 'defaultsettings', path: '/keybindings.json' });
|
||||
private readonly defaultSettingsRawResource = URI.from({ scheme: network.Schemas.vscode, authority: 'defaultsettings', path: '/defaultSettings.json' });
|
||||
|
||||
get userSettingsResource(): URI {
|
||||
return this.getEditableSettingsURI(ConfigurationTarget.USER);
|
||||
return this.getEditableSettingsURI(ConfigurationTarget.USER)!;
|
||||
}
|
||||
|
||||
get workspaceSettingsResource(): URI {
|
||||
get workspaceSettingsResource(): URI | null {
|
||||
return this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE);
|
||||
}
|
||||
|
||||
@@ -99,18 +99,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.instantiationService.createInstance(SettingsEditor2Input);
|
||||
}
|
||||
|
||||
getFolderSettingsResource(resource: URI): URI {
|
||||
getFolderSettingsResource(resource: URI): URI | null {
|
||||
return this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, resource);
|
||||
}
|
||||
|
||||
resolveModel(uri: URI): Promise<ITextModel> {
|
||||
resolveModel(uri: URI): Promise<ITextModel | null> {
|
||||
if (this.isDefaultSettingsResource(uri)) {
|
||||
|
||||
const target = this.getConfigurationTargetFromDefaultSettingsResource(uri);
|
||||
const languageSelection = this.modeService.create('jsonc');
|
||||
const model = this._register(this.modelService.createModel('', languageSelection, uri));
|
||||
|
||||
let defaultSettings: DefaultSettings;
|
||||
let defaultSettings: DefaultSettings | undefined;
|
||||
this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.source === ConfigurationTarget.DEFAULT) {
|
||||
const model = this.modelService.getModel(uri);
|
||||
@@ -134,9 +134,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}
|
||||
|
||||
if (this.defaultSettingsRawResource.toString() === uri.toString()) {
|
||||
let defaultSettings: DefaultSettings = this.getDefaultSettings(ConfigurationTarget.USER);
|
||||
const defaultRawSettingsEditorModel = this.instantiationService.createInstance(DefaultRawSettingsEditorModel, this.getDefaultSettings(ConfigurationTarget.USER));
|
||||
const languageSelection = this.modeService.create('jsonc');
|
||||
const model = this._register(this.modelService.createModel(defaultSettings.raw, languageSelection, uri));
|
||||
const model = this._register(this.modelService.createModel(defaultRawSettingsEditorModel.content, languageSelection, uri));
|
||||
return Promise.resolve(model);
|
||||
}
|
||||
|
||||
@@ -155,7 +155,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.createDefaultSettingsEditorModel(uri);
|
||||
}
|
||||
|
||||
if (this.getEditableSettingsURI(ConfigurationTarget.USER).toString() === uri.toString()) {
|
||||
if (this.userSettingsResource.toString() === uri.toString()) {
|
||||
return this.createEditableSettingsEditorModel(ConfigurationTarget.USER, uri);
|
||||
}
|
||||
|
||||
@@ -168,18 +168,18 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.createEditableSettingsEditorModel(ConfigurationTarget.WORKSPACE_FOLDER, uri);
|
||||
}
|
||||
|
||||
return Promise.resolve<IPreferencesEditorModel<any>>(null);
|
||||
return Promise.reject(`unknown resource: ${uri.toString()}`);
|
||||
}
|
||||
|
||||
openRawDefaultSettings(): Promise<IEditor> {
|
||||
openRawDefaultSettings(): Promise<IEditor | null> {
|
||||
return this.editorService.openEditor({ resource: this.defaultSettingsRawResource });
|
||||
}
|
||||
|
||||
openRawUserSettings(): Promise<IEditor> {
|
||||
openRawUserSettings(): Promise<IEditor | null> {
|
||||
return this.editorService.openEditor({ resource: this.userSettingsResource });
|
||||
}
|
||||
|
||||
openSettings(jsonEditor?: boolean): Promise<IEditor> {
|
||||
openSettings(jsonEditor?: boolean): Promise<IEditor | null> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -189,7 +189,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}
|
||||
|
||||
const editorInput = this.getActiveSettingsEditorInput() || this.lastOpenedSettingsInput;
|
||||
const resource = editorInput ? editorInput.master.getResource() : this.userSettingsResource;
|
||||
const resource = editorInput ? editorInput.master.getResource()! : this.userSettingsResource;
|
||||
const target = this.getConfigurationTargetFromSettingsResource(resource);
|
||||
return this.openOrSwitchSettings(target, resource);
|
||||
}
|
||||
@@ -197,10 +197,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
private openSettings2(): Promise<IEditor> {
|
||||
const input = this.settingsEditor2Input;
|
||||
return this.editorGroupService.activeGroup.openEditor(input)
|
||||
.then(() => this.editorGroupService.activeGroup.activeControl);
|
||||
.then(() => this.editorGroupService.activeGroup.activeControl!);
|
||||
}
|
||||
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
openGlobalSettings(jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
@@ -215,9 +215,9 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
|
||||
if (this.contextService.getWorkbenchState() === WorkbenchState.EMPTY) {
|
||||
if (!this.workspaceSettingsResource) {
|
||||
this.notificationService.info(nls.localize('openFolderFirst', "Open a folder first to create workspace settings"));
|
||||
return Promise.resolve(null);
|
||||
return Promise.reject(null);
|
||||
}
|
||||
|
||||
return jsonEditor ?
|
||||
@@ -225,26 +225,30 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE, undefined, options, group);
|
||||
}
|
||||
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
openFolderSettings(folder: URI, jsonEditor?: boolean, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
jsonEditor = typeof jsonEditor === 'undefined' ?
|
||||
this.configurationService.getValue('workbench.settings.editor') === 'json' :
|
||||
jsonEditor;
|
||||
|
||||
return jsonEditor ?
|
||||
this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE_FOLDER, this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, folder), options, group) :
|
||||
this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE_FOLDER, folder, options, group);
|
||||
const folderSettingsUri = this.getEditableSettingsURI(ConfigurationTarget.WORKSPACE_FOLDER, folder);
|
||||
if (jsonEditor) {
|
||||
if (folderSettingsUri) {
|
||||
return this.openOrSwitchSettings(ConfigurationTarget.WORKSPACE_FOLDER, folderSettingsUri, options, group);
|
||||
}
|
||||
return Promise.reject(`Invalid folder URI - ${folder.toString()}`);
|
||||
}
|
||||
return this.openOrSwitchSettings2(ConfigurationTarget.WORKSPACE_FOLDER, folder, options, group);
|
||||
}
|
||||
|
||||
switchSettings(target: ConfigurationTarget, resource: URI, jsonEditor?: boolean): Promise<void> {
|
||||
if (!jsonEditor) {
|
||||
return this.doOpenSettings2(target, resource).then(() => null);
|
||||
return this.doOpenSettings2(target, resource).then(() => undefined);
|
||||
}
|
||||
|
||||
const activeControl = this.editorService.activeControl;
|
||||
if (activeControl && activeControl.input instanceof PreferencesEditorInput) {
|
||||
return this.doSwitchSettings(target, resource, activeControl.input, activeControl.group).then(() => null);
|
||||
return this.doSwitchSettings(target, resource, activeControl.input, activeControl.group).then(() => undefined);
|
||||
} else {
|
||||
return this.doOpenSettings(target, resource).then(() => null);
|
||||
return this.doOpenSettings(target, resource).then(() => undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -275,10 +279,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
});
|
||||
}
|
||||
|
||||
return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true, revealIfOpened: true }).then(() => null);
|
||||
return this.editorService.openEditor(this.instantiationService.createInstance(KeybindingsEditorInput), { pinned: true, revealIfOpened: true }).then(() => undefined);
|
||||
}
|
||||
|
||||
openDefaultKeybindingsFile(): Promise<IEditor> {
|
||||
openDefaultKeybindingsFile(): Promise<IEditor | null> {
|
||||
return this.editorService.openEditor({ resource: this.defaultKeybindingsResource, label: nls.localize('defaultKeybindings', "Default Keybindings") });
|
||||
}
|
||||
|
||||
@@ -286,11 +290,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
this.openGlobalSettings(true)
|
||||
.then(editor => this.createPreferencesEditorModel(this.userSettingsResource)
|
||||
.then((settingsModel: IPreferencesEditorModel<ISetting>) => {
|
||||
const codeEditor = getCodeEditor(editor.getControl());
|
||||
const codeEditor = editor ? getCodeEditor(editor.getControl()) : null;
|
||||
if (codeEditor) {
|
||||
this.addLanguageOverrideEntry(language, settingsModel, codeEditor)
|
||||
.then(position => {
|
||||
if (codeEditor) {
|
||||
if (codeEditor && position) {
|
||||
codeEditor.setPosition(position);
|
||||
codeEditor.revealLine(position.lineNumber);
|
||||
codeEditor.focus();
|
||||
@@ -300,19 +304,22 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}));
|
||||
}
|
||||
|
||||
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor> {
|
||||
private openOrSwitchSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor | null> {
|
||||
const editorInput = this.getActiveSettingsEditorInput(group);
|
||||
if (editorInput && editorInput.master.getResource().fsPath !== resource.fsPath) {
|
||||
return this.doSwitchSettings(configurationTarget, resource, editorInput, group, options);
|
||||
if (editorInput) {
|
||||
const editorInputResource = editorInput.master.getResource();
|
||||
if (editorInputResource && editorInputResource.fsPath !== resource.fsPath) {
|
||||
return this.doSwitchSettings(configurationTarget, resource, editorInput, group, options);
|
||||
}
|
||||
}
|
||||
return this.doOpenSettings(configurationTarget, resource, options, group);
|
||||
}
|
||||
|
||||
private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor> {
|
||||
private openOrSwitchSettings2(configurationTarget: ConfigurationTarget, folderUri?: URI, options?: ISettingsEditorOptions, group: IEditorGroup = this.editorGroupService.activeGroup): Promise<IEditor | null> {
|
||||
return this.doOpenSettings2(configurationTarget, folderUri, options, group);
|
||||
}
|
||||
|
||||
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
private doOpenSettings(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
const openSplitJSON = !!this.configurationService.getValue(USE_SPLIT_JSON_SETTING);
|
||||
if (openSplitJSON) {
|
||||
return this.doOpenSplitJSON(configurationTarget, resource, options, group);
|
||||
@@ -334,14 +341,14 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return Promise.all([
|
||||
this.editorService.openEditor({ resource: this.defaultSettingsRawResource, options: { pinned: true, preserveFocus: true, revealIfOpened: true }, label: nls.localize('defaultSettings', "Default Settings"), description: '' }),
|
||||
this.editorService.openEditor(editableSettingsEditorInput, { pinned: true, revealIfOpened: true }, sideEditorGroup.id)
|
||||
]).then(() => null);
|
||||
]).then(([defaultEditor, editor]) => editor);
|
||||
} else {
|
||||
return this.editorService.openEditor(editableSettingsEditorInput, SettingsEditorOptions.create(options), group);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private doOpenSplitJSON(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
private doOpenSplitJSON(configurationTarget: ConfigurationTarget, resource: URI, options?: ISettingsEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
return this.getOrCreateEditableSettingsEditorInput(configurationTarget, resource)
|
||||
.then(editableSettingsEditorInput => {
|
||||
if (!options) {
|
||||
@@ -361,7 +368,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.instantiationService.createInstance(Settings2EditorModel, this.getDefaultSettings(ConfigurationTarget.USER));
|
||||
}
|
||||
|
||||
private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): Promise<IEditor> {
|
||||
private doOpenSettings2(target: ConfigurationTarget, folderUri: URI | undefined, options?: IEditorOptions, group?: IEditorGroup): Promise<IEditor | null> {
|
||||
const input = this.settingsEditor2Input;
|
||||
const settingsOptions: ISettingsEditorOptions = {
|
||||
...options,
|
||||
@@ -373,7 +380,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
}
|
||||
|
||||
private doSwitchSettings(target: ConfigurationTarget, resource: URI, input: PreferencesEditorInput, group: IEditorGroup, options?: ISettingsEditorOptions): Promise<IEditor> {
|
||||
return this.getOrCreateEditableSettingsEditorInput(target, this.getEditableSettingsURI(target, resource))
|
||||
const settingsURI = this.getEditableSettingsURI(target, resource);
|
||||
if (!settingsURI) {
|
||||
return Promise.reject(`Invalid settings URI - ${resource.toString()}`);
|
||||
}
|
||||
return this.getOrCreateEditableSettingsEditorInput(target, settingsURI)
|
||||
.then(toInput => {
|
||||
return group.openEditor(input).then(() => {
|
||||
const replaceWith = new PreferencesEditorInput(this.getPreferencesEditorInputName(target, resource), toInput.getDescription(), this.instantiationService.createInstance(DefaultPreferencesEditorInput, this.getDefaultSettingsResource(target)), toInput);
|
||||
@@ -381,10 +392,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return group.replaceEditors([{
|
||||
editor: input,
|
||||
replacement: replaceWith,
|
||||
options: SettingsEditorOptions.create(options)
|
||||
options: options ? SettingsEditorOptions.create(options) : undefined
|
||||
}]).then(() => {
|
||||
this.lastOpenedSettingsInput = replaceWith;
|
||||
return group.activeControl;
|
||||
return group.activeControl!;
|
||||
});
|
||||
});
|
||||
});
|
||||
@@ -463,7 +474,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this.textModelResolverService.createModelReference(settingsUri)
|
||||
.then(reference => this.instantiationService.createInstance(SettingsEditorModel, reference, configurationTarget));
|
||||
}
|
||||
return Promise.resolve<SettingsEditorModel>(null);
|
||||
return Promise.reject(`unknown target: ${configurationTarget} and resource: ${resource.toString()}`);
|
||||
}
|
||||
|
||||
private createDefaultSettingsEditorModel(defaultSettingsUri: URI): Promise<DefaultSettingsEditorModel> {
|
||||
@@ -493,7 +504,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
return this._defaultUserSettingsContentModel;
|
||||
}
|
||||
|
||||
private getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): URI {
|
||||
private getEditableSettingsURI(configurationTarget: ConfigurationTarget, resource?: URI): URI | null {
|
||||
switch (configurationTarget) {
|
||||
case ConfigurationTarget.USER:
|
||||
return URI.file(this.environmentService.appSettingsPath);
|
||||
@@ -504,8 +515,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
const workspace = this.contextService.getWorkspace();
|
||||
return workspace.configuration || workspace.folders[0].toResource(FOLDER_SETTINGS_PATH);
|
||||
case ConfigurationTarget.WORKSPACE_FOLDER:
|
||||
const folder = this.contextService.getWorkspaceFolder(resource);
|
||||
return folder ? folder.toResource(FOLDER_SETTINGS_PATH) : null;
|
||||
if (resource) {
|
||||
const folder = this.contextService.getWorkspaceFolder(resource);
|
||||
return folder ? folder.toResource(FOLDER_SETTINGS_PATH) : null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
@@ -522,7 +535,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
if (Object.keys(parse(content.value)).indexOf('settings') === -1) {
|
||||
return this.jsonEditingService.write(resource, { key: 'settings', value: {} }, true).then(undefined, () => { });
|
||||
}
|
||||
return null;
|
||||
return undefined;
|
||||
});
|
||||
}
|
||||
return this.createIfNotExists(resource, emptyEditableSettingsContent).then(() => { });
|
||||
@@ -556,29 +569,35 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
];
|
||||
}
|
||||
|
||||
private addLanguageOverrideEntry(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): Promise<IPosition> {
|
||||
private addLanguageOverrideEntry(language: string, settingsModel: IPreferencesEditorModel<ISetting>, codeEditor: ICodeEditor): Promise<IPosition | null> {
|
||||
const languageKey = `[${language}]`;
|
||||
let setting = settingsModel.getPreference(languageKey);
|
||||
const model = codeEditor.getModel();
|
||||
const configuration = this.configurationService.getValue<{ editor: { tabSize: number; insertSpaces: boolean } }>();
|
||||
const eol = model.getEOL();
|
||||
if (setting) {
|
||||
if (setting.overrides.length) {
|
||||
const lastSetting = setting.overrides[setting.overrides.length - 1];
|
||||
return Promise.resolve({ lineNumber: lastSetting.valueRange.endLineNumber, column: model.getLineMaxColumn(lastSetting.valueRange.endLineNumber) });
|
||||
if (model) {
|
||||
const configuration = this.configurationService.getValue<{ editor: { tabSize: number; insertSpaces: boolean } }>();
|
||||
const eol = model.getEOL();
|
||||
if (setting) {
|
||||
if (setting.overrides && setting.overrides.length) {
|
||||
const lastSetting = setting.overrides[setting.overrides.length - 1];
|
||||
return Promise.resolve({ lineNumber: lastSetting.valueRange.endLineNumber, column: model.getLineMaxColumn(lastSetting.valueRange.endLineNumber) });
|
||||
}
|
||||
return Promise.resolve({ lineNumber: setting.valueRange.startLineNumber, column: setting.valueRange.startColumn + 1 });
|
||||
}
|
||||
return Promise.resolve({ lineNumber: setting.valueRange.startLineNumber, column: setting.valueRange.startColumn + 1 });
|
||||
return this.configurationService.updateValue(languageKey, {}, ConfigurationTarget.USER)
|
||||
.then(() => {
|
||||
setting = settingsModel.getPreference(languageKey);
|
||||
if (setting) {
|
||||
let content = eol + this.spaces(2, configuration.editor) + eol + this.spaces(1, configuration.editor);
|
||||
let editOperation = EditOperation.insert(new Position(setting.valueRange.endLineNumber, setting.valueRange.endColumn - 1), content);
|
||||
model.pushEditOperations([], [editOperation], () => []);
|
||||
let lineNumber = setting.valueRange.endLineNumber + 1;
|
||||
settingsModel.dispose();
|
||||
return { lineNumber, column: model.getLineMaxColumn(lineNumber) };
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
return this.configurationService.updateValue(languageKey, {}, ConfigurationTarget.USER)
|
||||
.then(() => {
|
||||
setting = settingsModel.getPreference(languageKey);
|
||||
let content = eol + this.spaces(2, configuration.editor) + eol + this.spaces(1, configuration.editor);
|
||||
let editOperation = EditOperation.insert(new Position(setting.valueRange.endLineNumber, setting.valueRange.endColumn - 1), content);
|
||||
model.pushEditOperations([], [editOperation], () => []);
|
||||
let lineNumber = setting.valueRange.endLineNumber + 1;
|
||||
settingsModel.dispose();
|
||||
return { lineNumber, column: model.getLineMaxColumn(lineNumber) };
|
||||
});
|
||||
return Promise.resolve(null);
|
||||
}
|
||||
|
||||
private spaces(count: number, { tabSize, insertSpaces }: { tabSize: number; insertSpaces: boolean }): string {
|
||||
@@ -590,3 +609,5 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IPreferencesService, PreferencesService);
|
||||
Reference in New Issue
Block a user