From cfd06442d82ecb98e925a7e5c032738c1c955e4a Mon Sep 17 00:00:00 2001 From: Sandeep Somavarapu Date: Mon, 17 Jul 2017 14:30:00 +0530 Subject: [PATCH] #30838 : Naming of files explorer section - Always show workspace name - Section root should be folder in case of single folder workspace --- .../workbench/parts/files/browser/views/explorerView.ts | 9 +++++---- .../services/configuration/node/configuration.ts | 2 -- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 3d900ba57fb..d2f2bd57cd1 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -142,8 +142,7 @@ export class ExplorerView extends CollapsibleView { } public get name(): string { - const workspace = this.contextService.getWorkspace(); - return workspace.roots.length === 1 ? workspace.name : nls.localize('folders', "Folders"); + return this.contextService.getWorkspace().name; } public set name(value) { @@ -727,6 +726,8 @@ export class ExplorerView extends CollapsibleView { let targetsToExpand: URI[] = []; if (this.settings[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES]) { targetsToExpand = this.settings[ExplorerView.MEMENTO_EXPANDED_FOLDER_RESOURCES].map((e: string) => URI.parse(e)); + } else if (this.contextService.hasFolderWorkspace()) { + targetsToExpand = this.model.roots.map(root => root.resource); // always expand single folder workspace } // First time refresh: Receive target through active editor input or selection and also include settings from previous session @@ -776,7 +777,7 @@ export class ExplorerView extends CollapsibleView { // Subsequent refresh: Merge stat into our local model and refresh tree modelStats.forEach((modelStat, index) => FileStat.mergeLocalWithDisk(modelStat, this.model.roots[index])); - const input = this.model.roots.length === 1 ? this.model.roots[0] : this.model; + const input = this.contextService.hasFolderWorkspace() ? this.model.roots[0] : this.model; if (input === this.explorerViewer.getInput()) { return this.explorerViewer.refresh(); } @@ -787,7 +788,7 @@ export class ExplorerView extends CollapsibleView { const statsToExpand = expanded.length ? [this.model.roots[0]].concat(expanded) : targetsToExpand.map(expand => this.model.findClosest(expand)); - // Display roots only when there is more than 1 root + // Display roots only when multi folder workspace // Make sure to expand all folders that where expanded in the previous session return this.explorerViewer.setInput(input).then(() => this.explorerViewer.expandAll(statsToExpand)); }, e => TPromise.wrapError(e)); diff --git a/src/vs/workbench/services/configuration/node/configuration.ts b/src/vs/workbench/services/configuration/node/configuration.ts index 17243383c2d..fa6787dfb63 100644 --- a/src/vs/workbench/services/configuration/node/configuration.ts +++ b/src/vs/workbench/services/configuration/node/configuration.ts @@ -27,7 +27,6 @@ import { WorkspaceConfigurationModel, ScopedConfigurationModel, FolderConfigurat import { IConfigurationServiceEvent, ConfigurationSource, IConfigurationKeys, IConfigurationValue, ConfigurationModel, IConfigurationOverrides, Configuration as BaseConfiguration, IConfigurationValues, IConfigurationData } from 'vs/platform/configuration/common/configuration'; import { IWorkspaceConfigurationService, WORKSPACE_CONFIG_FOLDER_DEFAULT_NAME, WORKSPACE_STANDALONE_CONFIGURATIONS, WORKSPACE_CONFIG_DEFAULT_PATH } from 'vs/workbench/services/configuration/common/configuration'; import { ConfigurationService as GlobalConfigurationService } from 'vs/platform/configuration/node/configurationService'; -import { basename } from 'path'; import * as nls from 'vs/nls'; import { Registry } from 'vs/platform/registry/common/platform'; import { ExtensionsRegistry, ExtensionMessageCollector } from 'vs/platform/extensions/common/extensionsRegistry'; @@ -464,7 +463,6 @@ export class WorkspaceServiceImpl extends WorkspaceService { const foldersChanged = !equals(this.workspace.roots, configuredFolders, (r1, r2) => r1.toString() === r2.toString()); if (foldersChanged) { this.workspace.roots = configuredFolders; - this.workspace.name = configuredFolders.map(root => basename(root.fsPath) || root.fsPath).join(', '); this._onDidChangeWorkspaceRoots.fire(); this.onFoldersChanged(); return; -- GitLab