diff --git a/extensions/configuration-editing/src/settingsDocumentHelper.ts b/extensions/configuration-editing/src/settingsDocumentHelper.ts index 6ca6efe6a0c..e1b8ade4507 100644 --- a/extensions/configuration-editing/src/settingsDocumentHelper.ts +++ b/extensions/configuration-editing/src/settingsDocumentHelper.ts @@ -38,9 +38,9 @@ export class SettingsDocument { private provideWindowTitleCompletionItems(location: Location, range: vscode.Range): vscode.ProviderResult { const completions: vscode.CompletionItem[] = []; - completions.push(this.newSimpleCompletionItem('${activeEditorName}', range, localize('activeEditorName', "e.g. myFile.txt"))); - completions.push(this.newSimpleCompletionItem('${activeFilePath}', range, localize('activeFilePath', "e.g. /Users/Development/myProject/myFolder/myFile.txt"))); - completions.push(this.newSimpleCompletionItem('${activeFilePathRelative}', range, localize('activeFilePathRelative', "e.g. /Users/Development/myProject/myFolder/myFile.txt"))); + completions.push(this.newSimpleCompletionItem('${activeEditorShort}', range, localize('activeEditorShort', "e.g. myFile.txt"))); + completions.push(this.newSimpleCompletionItem('${activeEditorMedium}', range, localize('activeEditorMedium', "e.g. myFolder/myFile.txt"))); + completions.push(this.newSimpleCompletionItem('${activeEditorLong}', range, localize('activeEditorLong', "e.g. /Users/Development/myProject/myFolder/myFile.txt"))); completions.push(this.newSimpleCompletionItem('${rootName}', range, localize('rootName', "e.g. myProject"))); completions.push(this.newSimpleCompletionItem('${rootPath}', range, localize('rootPath', "e.g. /Users/Development/myProject"))); completions.push(this.newSimpleCompletionItem('${appName}', range, localize('appName', "e.g. VS Code"))); diff --git a/src/vs/base/test/common/labels.test.ts b/src/vs/base/test/common/labels.test.ts index 7c0fcc1bb86..9bbc77e9129 100644 --- a/src/vs/base/test/common/labels.test.ts +++ b/src/vs/base/test/common/labels.test.ts @@ -123,18 +123,18 @@ suite('Labels', () => { assert.strictEqual(labels.template('${value} Foo${separator}Bar', { value: 'something', separator: { label: ' - ' } }), 'something FooBar'); // // real world example (macOS) - let t = '${activeEditorName}${separator}${rootName}'; - assert.strictEqual(labels.template(t, { activeEditorName: '', rootName: '', separator: { label: ' - ' } }), ''); - assert.strictEqual(labels.template(t, { activeEditorName: '', rootName: 'root', separator: { label: ' - ' } }), 'root'); - assert.strictEqual(labels.template(t, { activeEditorName: 'markdown.txt', rootName: 'root', separator: { label: ' - ' } }), 'markdown.txt - root'); + let t = '${activeEditorShort}${separator}${rootName}'; + assert.strictEqual(labels.template(t, { activeEditorShort: '', rootName: '', separator: { label: ' - ' } }), ''); + assert.strictEqual(labels.template(t, { activeEditorShort: '', rootName: 'root', separator: { label: ' - ' } }), 'root'); + assert.strictEqual(labels.template(t, { activeEditorShort: 'markdown.txt', rootName: 'root', separator: { label: ' - ' } }), 'markdown.txt - root'); // // real world example (other) - t = '${dirty}${activeEditorName}${separator}${rootName}${separator}${appName}'; - assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: '', appName: '', separator: { label: ' - ' } }), ''); - assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: '', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'Visual Studio Code'); - assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: 'Untitled-1', rootName: '', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'Untitled-1 - Visual Studio Code'); - assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'monaco - Visual Studio Code'); - assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: 'somefile.txt', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'somefile.txt - monaco - Visual Studio Code'); - assert.strictEqual(labels.template(t, { dirty: '* ', activeEditorName: 'somefile.txt', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), '* somefile.txt - monaco - Visual Studio Code'); + t = '${dirty}${activeEditorShort}${separator}${rootName}${separator}${appName}'; + assert.strictEqual(labels.template(t, { dirty: '', activeEditorShort: '', rootName: '', appName: '', separator: { label: ' - ' } }), ''); + assert.strictEqual(labels.template(t, { dirty: '', activeEditorShort: '', rootName: '', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'Visual Studio Code'); + assert.strictEqual(labels.template(t, { dirty: '', activeEditorShort: 'Untitled-1', rootName: '', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'Untitled-1 - Visual Studio Code'); + assert.strictEqual(labels.template(t, { dirty: '', activeEditorShort: '', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'monaco - Visual Studio Code'); + assert.strictEqual(labels.template(t, { dirty: '', activeEditorShort: 'somefile.txt', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'somefile.txt - monaco - Visual Studio Code'); + assert.strictEqual(labels.template(t, { dirty: '* ', activeEditorShort: 'somefile.txt', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), '* somefile.txt - monaco - Visual Studio Code'); }); }); \ No newline at end of file diff --git a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts index b47216ad520..cd3a1bf23e7 100644 --- a/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts +++ b/src/vs/workbench/browser/parts/titlebar/titlebarPart.ts @@ -151,9 +151,9 @@ export class TitlebarPart extends Part implements ITitleService { /** * Possible template values: * - * {activeEditorName}: e.g. myFile.txt - * {activeFilePath}: e.g. /Users/Development/myProject/myFolder/myFile.txt - * {activeFilePathRelative}: e.g. myFolder/myFile.txt + * {activeEditorLong}: e.g. /Users/Development/myProject/myFolder/myFile.txt + * {activeEditorMedium}: e.g. myFolder/myFile.txt + * {activeEditorShort}: e.g. myFile.txt * {rootName}: e.g. myProject * {rootPath}: e.g. /Users/Development/myProject * {appName}: e.g. VS Code @@ -166,9 +166,9 @@ export class TitlebarPart extends Part implements ITitleService { const file = toResource(input, { filter: 'file' }); // Variables - const activeEditorName = input ? input.getName() : ''; - const activeFilePath = file ? this.tildify(labels.getPathLabel(file)) : ''; - const activeFilePathRelative = file ? labels.getPathLabel(file, this.contextService) : ''; + const activeEditorShort = input ? input.getName() : ''; + const activeEditorMedium = file ? labels.getPathLabel(file, this.contextService) : activeEditorShort; + const activeEditorLong = file ? this.tildify(labels.getPathLabel(file)) : activeEditorMedium; const rootName = workspace ? workspace.name : ''; const rootPath = workspace ? this.workspacePath : ''; const dirty = input && input.isDirty() ? TitlebarPart.TITLE_DIRTY : ''; @@ -176,9 +176,9 @@ export class TitlebarPart extends Part implements ITitleService { const separator = TitlebarPart.TITLE_SEPARATOR; return labels.template(this.titleTemplate, { - activeEditorName, - activeFilePath, - activeFilePathRelative, + activeEditorShort, + activeEditorLong, + activeEditorMedium, rootName, rootPath, dirty, diff --git a/src/vs/workbench/electron-browser/main.contribution.ts b/src/vs/workbench/electron-browser/main.contribution.ts index 544c9c08972..bf875a64617 100644 --- a/src/vs/workbench/electron-browser/main.contribution.ts +++ b/src/vs/workbench/electron-browser/main.contribution.ts @@ -196,12 +196,12 @@ Note that there can still be cases where this setting is ignored (e.g. when usin }, 'window.title': { 'type': 'string', - 'default': isMacintosh ? '${activeEditorName}${separator}${rootName}' : '${dirty}${activeEditorName}${separator}${rootName}${separator}${appName}', + 'default': isMacintosh ? '${activeEditorShort}${separator}${rootName}' : '${dirty}${activeEditorShort}${separator}${rootName}${separator}${appName}', 'description': nls.localize({ comment: ['This is the description for a setting. Values surrounded by parenthesis are not to be translated.'], key: 'title' }, `Controls the window title based on the active editor. Variables are substituted based on the context: -\${activeEditorName}: e.g. myFile.txt -\${activeFilePath}: e.g. /Users/Development/myProject/myFolder/myFile.txt -\${activeFilePathRelative}: e.g. myFolder/myFile.txt +\${activeEditorShort}: e.g. myFile.txt +\${activeEditorMedium}: e.g. myFolder/myFile.txt +\${activeEditorLong}: e.g. /Users/Development/myProject/myFolder/myFile.txt \${rootName}: e.g. myProject \${rootPath}: e.g. /Users/Development/myProject \${appName}: e.g. VS Code