Skip to content

Commit

Permalink
#66907 💄
Browse files Browse the repository at this point in the history
  • Loading branch information
sandy081 committed Jan 23, 2019
1 parent 2d79ffe commit 11f3201
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
19 changes: 12 additions & 7 deletions src/vs/workbench/services/configuration/node/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { isLinux } from 'vs/base/common/platform';
import { ConfigurationModel } from 'vs/platform/configuration/common/configurationModels';
import { WorkspaceConfigurationModelParser, FolderSettingsModelParser, StandaloneConfigurationModelParser } from 'vs/workbench/services/configuration/common/configurationModels';
import { FOLDER_SETTINGS_PATH, TASKS_CONFIGURATION_KEY, FOLDER_SETTINGS_NAME, LAUNCH_CONFIGURATION_KEY } from 'vs/workbench/services/configuration/common/configuration';
import { IStoredWorkspaceFolder, IWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces';
import { IStoredWorkspaceFolder } from 'vs/platform/workspaces/common/workspaces';
import * as extfs from 'vs/base/node/extfs';
import { JSONEditingService } from 'vs/workbench/services/configuration/node/jsonEditingService';
import { WorkbenchState, IWorkspaceFolder } from 'vs/platform/workspace/common/workspace';
Expand All @@ -29,6 +29,11 @@ import { Schemas } from 'vs/base/common/network';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IConfigurationModel } from 'vs/platform/configuration/common/configuration';

export interface IWorkspaceIdentifier {
id: string;
configPath: URI;
}

export class WorkspaceConfiguration extends Disposable {

private readonly _cachedConfiguration: CachedWorkspaceConfiguration;
Expand Down Expand Up @@ -75,7 +80,7 @@ export class WorkspaceConfiguration extends Disposable {

setFolders(folders: IStoredWorkspaceFolder[], jsonEditingService: JSONEditingService): Promise<void> {
if (this._workspaceIdentifier) {
return jsonEditingService.write(URI.file(this._workspaceIdentifier.configPath), { key: 'folders', value: folders }, true)
return jsonEditingService.write(this._workspaceIdentifier.configPath, { key: 'folders', value: folders }, true)
.then(() => this.reload());
}
return Promise.resolve();
Expand All @@ -102,7 +107,7 @@ export class WorkspaceConfiguration extends Disposable {
}
return false;
}
if (URI.file(this._workspaceIdentifier.configPath).scheme === Schemas.file) {
if (this._workspaceIdentifier.configPath.scheme === Schemas.file) {
if (!(this._workspaceConfiguration instanceof NodeBasedWorkspaceConfiguration)) {
dispose(this._workspaceConfiguration);
this._workspaceConfiguration = new NodeBasedWorkspaceConfiguration();
Expand All @@ -120,7 +125,7 @@ export class WorkspaceConfiguration extends Disposable {
}

private updateCache(): Promise<void> {
if (this._workspaceIdentifier && URI.file(this._workspaceIdentifier.configPath).scheme !== Schemas.file && this._workspaceConfiguration instanceof FileServiceBasedWorkspaceConfiguration) {
if (this._workspaceIdentifier && this._workspaceIdentifier.configPath.scheme !== Schemas.file && this._workspaceConfiguration instanceof FileServiceBasedWorkspaceConfiguration) {
return this._workspaceConfiguration.load(this._workspaceIdentifier)
.then(() => this._cachedConfiguration.updateWorkspace(this._workspaceIdentifier, this._workspaceConfiguration.getConfigurationModel()));
}
Expand Down Expand Up @@ -195,7 +200,7 @@ abstract class AbstractWorkspaceConfiguration extends Disposable implements IWor
class NodeBasedWorkspaceConfiguration extends AbstractWorkspaceConfiguration {

protected loadWorkspaceConfigurationContents(workspaceIdentifier: IWorkspaceIdentifier): Promise<string> {
return pfs.readFile(workspaceIdentifier.configPath)
return pfs.readFile(workspaceIdentifier.configPath.fsPath)
.then(contents => contents.toString(), e => {
errors.onUnexpectedError(e);
return '';
Expand All @@ -211,13 +216,13 @@ class FileServiceBasedWorkspaceConfiguration extends AbstractWorkspaceConfigurat

constructor(private fileService: IFileService, from?: AbstractWorkspaceConfiguration) {
super(from);
this.workspaceConfig = from ? URI.file(from.workspaceIdentifier.configPath) : null;
this.workspaceConfig = from ? from.workspaceIdentifier.configPath : null;
this._register(fileService.onFileChanges(e => this.handleWorkspaceFileEvents(e)));
this.reloadConfigurationScheduler = this._register(new RunOnceScheduler(() => this._onDidChange.fire(), 50));
}

protected loadWorkspaceConfigurationContents(workspaceIdentifier: IWorkspaceIdentifier): Promise<string> {
this.workspaceConfig = URI.file(workspaceIdentifier.configPath);
this.workspaceConfig = workspaceIdentifier.configPath;
return this.fileService.resolveContent(this.workspaceConfig)
.then(content => content.value, e => {
errors.onUnexpectedError(e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
}

private createMultiFolderWorkspace(workspaceIdentifier: IWorkspaceIdentifier): Promise<Workspace> {
return this.workspaceConfiguration.load(workspaceIdentifier)
return this.workspaceConfiguration.load({ id: workspaceIdentifier.id, configPath: URI.file(workspaceIdentifier.configPath) })
.then(() => {
const workspaceConfigPath = URI.file(workspaceIdentifier.configPath);
const workspaceFolders = toWorkspaceFolders(this.workspaceConfiguration.getFolders(), URI.file(dirname(workspaceConfigPath.fsPath)));
Expand Down

0 comments on commit 11f3201

Please sign in to comment.