From 7714e993a6e25c8e31e711c51d32a9af8e31dc78 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Thu, 9 Feb 2017 09:20:31 +0100 Subject: [PATCH] Missing dash separating filename from Code application title (fixes #20236) --- src/vs/base/common/labels.ts | 5 ++++- src/vs/base/test/common/labels.test.ts | 1 + 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/vs/base/common/labels.ts b/src/vs/base/common/labels.ts index cbf8dac5d46..e543ff015a4 100644 --- a/src/vs/base/common/labels.ts +++ b/src/vs/base/common/labels.ts @@ -189,7 +189,10 @@ export function template(template: string, values: { [key: string]: string | ISe // Separator else if (resolved) { - segments.push({ value: resolved.label, type: Type.SEPARATOR }); + const prevSegment = segments[segments.length - 1]; + if (!prevSegment || prevSegment.type !== Type.SEPARATOR) { + segments.push({ value: resolved.label, type: Type.SEPARATOR }); // prevent duplicate separators + } } curVal = ''; diff --git a/src/vs/base/test/common/labels.test.ts b/src/vs/base/test/common/labels.test.ts index ecbe0551e30..670908c0049 100644 --- a/src/vs/base/test/common/labels.test.ts +++ b/src/vs/base/test/common/labels.test.ts @@ -125,6 +125,7 @@ suite('Labels', () => { 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'); -- GitLab