提交 998ed03e 编写于 作者: S Sandeep Somavarapu

Fix #30838

上级 cfd06442
......@@ -521,6 +521,9 @@ export class SimpleWorkspaceContextService implements IWorkspaceContextService {
private static SCHEME: 'inmemory';
private readonly _onDidChangeWorkspaceName: Emitter<void> = new Emitter<void>();
public readonly onDidChangeWorkspaceName: Event<void> = this._onDidChangeWorkspaceName.event;
private readonly _onDidChangeWorkspaceRoots: Emitter<void> = new Emitter<void>();
public readonly onDidChangeWorkspaceRoots: Event<void> = this._onDidChangeWorkspaceRoots.event;
......
......@@ -48,6 +48,11 @@ export interface IWorkspaceContextService {
*/
saveWorkspace(location: URI): TPromise<void>;
/**
* An event which fires on workspace name changes.
*/
onDidChangeWorkspaceName: Event<void>;
/**
* An event which fires on workspace roots change.
*/
......
......@@ -135,7 +135,7 @@ export class ExplorerView extends CollapsibleView {
const title = workspace.roots.map(root => labels.getPathLabel(root.fsPath, void 0, this.environmentService)).join();
titleSpan.text(this.name).title(title);
};
this.toDispose.push(this.contextService.onDidChangeWorkspaceRoots(() => setHeader()));
this.toDispose.push(this.contextService.onDidChangeWorkspaceName(() => setHeader()));
setHeader();
super.renderHeader(container);
......
......@@ -174,6 +174,9 @@ export class WorkspaceService extends Disposable implements IWorkspaceConfigurat
protected readonly _onDidChangeWorkspaceRoots: Emitter<void> = this._register(new Emitter<void>());
public readonly onDidChangeWorkspaceRoots: Event<void> = this._onDidChangeWorkspaceRoots.event;
protected readonly _onDidChangeWorkspaceName: Emitter<void> = this._register(new Emitter<void>());
public readonly onDidChangeWorkspaceName: Event<void> = this._onDidChangeWorkspaceName.event;
constructor() {
super();
this._configuration = new Configuration(new BaseConfiguration(new ConfigurationModel<any>(), new ConfigurationModel<any>()), new ConfigurationModel<any>(), new StrictResourceMap<FolderConfigurationModel<any>>(), this.workspace);
......@@ -392,6 +395,7 @@ export class WorkspaceServiceImpl extends WorkspaceService {
}
private onWorkspaceSaved(configPath: URI): TPromise<void> {
let workspaceName = this.workspace.name;
this.workspaceConfigPath = configPath;
// Reset the workspace if current workspace is single folder
......@@ -403,9 +407,14 @@ export class WorkspaceServiceImpl extends WorkspaceService {
// Update workspace configuration path with new path
else {
this.workspace.configuration = configPath;
this.workspace.name = getWorkspaceLabel(this.environmentService, { id: this.workspace.id, configPath: this.workspace.configuration.fsPath });
}
return this.initialize();
return this.initialize().then(() => {
if (workspaceName !== this.workspace.name) {
this._onDidChangeWorkspaceName.fire();
}
});
}
private initializeMulitFolderWorkspace(): TPromise<void> {
......
......@@ -70,6 +70,7 @@ export class TestContextService implements IWorkspaceContextService {
private id: string;
private options: any;
private _onDidChangeWorkspaceName: Emitter<void>;
private _onDidChangeWorkspaceRoots: Emitter<void>;
constructor(workspace: any = TestWorkspace, options: any = null) {
......@@ -79,6 +80,10 @@ export class TestContextService implements IWorkspaceContextService {
this._onDidChangeWorkspaceRoots = new Emitter<void>();
}
public get onDidChangeWorkspaceName(): Event<void> {
return this._onDidChangeWorkspaceName.event;
}
public get onDidChangeWorkspaceRoots(): Event<void> {
return this._onDidChangeWorkspaceRoots.event;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册