Skip to content

Commit 29c4e31

Browse files
author
Benjamin Pasero
committed
window title: convert variable format from $() to ${}
1 parent fcfa0c3 commit 29c4e31

4 files changed

Lines changed: 27 additions & 27 deletions

File tree

extensions/json/server/src/jsoncontributions/windowTitleContribution.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,13 @@ export class WindowTitleContribution implements JSONWorkerContribution {
3636
if (this.isSettingsFile(resource) && location.length === 1 && location[0] === 'window.title') {
3737
return Promise.resolve([
3838
MarkedString.fromPlainText(localize('windowTitle.description', "Controls the window title based on the active editor. Variables are substituted based on the context:")),
39-
MarkedString.fromPlainText(localize('windowTitle.activeEditorName', "$(activeEditorName): e.g. myFile.txt")),
40-
MarkedString.fromPlainText(localize('windowTitle.activeFilePath', "$(activeFilePath): e.g. /Users/Development/myProject/myFile.txt")),
41-
MarkedString.fromPlainText(localize('windowTitle.rootName', "$(rootName): e.g. myProject")),
42-
MarkedString.fromPlainText(localize('windowTitle.rootPath', "$(rootPath): e.g. /Users/Development/myProject")),
43-
MarkedString.fromPlainText(localize('windowTitle.appName', "$(appName): e.g. VS Code")),
44-
MarkedString.fromPlainText(localize('windowTitle.dirty', "$(dirty): a dirty indicator if the active editor is dirty")),
45-
MarkedString.fromPlainText(localize('windowTitle.separator', "$(separator): a conditional separator (\" - \") that only shows when surrounded by variables with values"))
39+
MarkedString.fromPlainText(localize('windowTitle.activeEditorName', "${activeEditorName}: e.g. myFile.txt")),
40+
MarkedString.fromPlainText(localize('windowTitle.activeFilePath', "${activeFilePath}: e.g. /Users/Development/myProject/myFile.txt")),
41+
MarkedString.fromPlainText(localize('windowTitle.rootName', "${rootName}: e.g. myProject")),
42+
MarkedString.fromPlainText(localize('windowTitle.rootPath', "${rootPath}: e.g. /Users/Development/myProject")),
43+
MarkedString.fromPlainText(localize('windowTitle.appName', "${appName}: e.g. VS Code")),
44+
MarkedString.fromPlainText(localize('windowTitle.dirty', "${dirty}: a dirty indicator if the active editor is dirty")),
45+
MarkedString.fromPlainText(localize('windowTitle.separator', "${separator}: a conditional separator (\" - \") that only shows when surrounded by variables with values"))
4646
]);
4747
}
4848

src/vs/base/common/labels.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ export function template(template: string, values: { [key: string]: string | ISe
167167
char = template[i];
168168

169169
// Beginning of variable
170-
if (char === '$' || (inVariable && char === '(')) {
170+
if (char === '$' || (inVariable && char === '{')) {
171171
if (curVal) {
172172
segments.push({ value: curVal, type: Type.TEXT });
173173
}
@@ -177,7 +177,7 @@ export function template(template: string, values: { [key: string]: string | ISe
177177
}
178178

179179
// End of variable
180-
else if (char === ')' && inVariable) {
180+
else if (char === '}' && inVariable) {
181181
const resolved = values[curVal];
182182

183183
// Variable

src/vs/base/test/common/labels.test.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,26 +103,26 @@ suite('Labels', () => {
103103

104104
// simple
105105
assert.strictEqual(labels.template('Foo Bar'), 'Foo Bar');
106-
assert.strictEqual(labels.template('Foo$()Bar'), 'FooBar');
106+
assert.strictEqual(labels.template('Foo${}Bar'), 'FooBar');
107107
assert.strictEqual(labels.template('$FooBar'), '');
108-
assert.strictEqual(labels.template(')FooBar'), ')FooBar');
109-
assert.strictEqual(labels.template('Foo $(one) Bar', { one: 'value' }), 'Foo value Bar');
110-
assert.strictEqual(labels.template('Foo $(one) Bar $(two)', { one: 'value', two: 'other value' }), 'Foo value Bar other value');
108+
assert.strictEqual(labels.template('}FooBar'), '}FooBar');
109+
assert.strictEqual(labels.template('Foo ${one} Bar', { one: 'value' }), 'Foo value Bar');
110+
assert.strictEqual(labels.template('Foo ${one} Bar ${two}', { one: 'value', two: 'other value' }), 'Foo value Bar other value');
111111

112112
// conditional separator
113-
assert.strictEqual(labels.template('Foo$(separator)Bar'), 'FooBar');
114-
assert.strictEqual(labels.template('Foo$(separator)Bar', { separator: { label: ' - ' } }), 'FooBar');
115-
assert.strictEqual(labels.template('$(separator)Foo$(separator)Bar', { value: 'something', separator: { label: ' - ' } }), 'FooBar');
116-
assert.strictEqual(labels.template('$(value) Foo$(separator)Bar', { value: 'something', separator: { label: ' - ' } }), 'something FooBar');
113+
assert.strictEqual(labels.template('Foo${separator}Bar'), 'FooBar');
114+
assert.strictEqual(labels.template('Foo${separator}Bar', { separator: { label: ' - ' } }), 'FooBar');
115+
assert.strictEqual(labels.template('${separator}Foo${separator}Bar', { value: 'something', separator: { label: ' - ' } }), 'FooBar');
116+
assert.strictEqual(labels.template('${value} Foo${separator}Bar', { value: 'something', separator: { label: ' - ' } }), 'something FooBar');
117117

118118
// // real world example (macOS)
119-
let t = '$(activeEditorName)$(separator)$(rootName)';
119+
let t = '${activeEditorName}${separator}${rootName}';
120120
assert.strictEqual(labels.template(t, { activeEditorName: '', rootName: '', separator: { label: ' - ' } }), '');
121121
assert.strictEqual(labels.template(t, { activeEditorName: '', rootName: 'root', separator: { label: ' - ' } }), 'root');
122122
assert.strictEqual(labels.template(t, { activeEditorName: 'markdown.txt', rootName: 'root', separator: { label: ' - ' } }), 'markdown.txt - root');
123123

124124
// // real world example (other)
125-
t = '$(dirty)$(activeEditorName)$(separator)$(rootName)$(separator)$(appName)';
125+
t = '${dirty}${activeEditorName}${separator}${rootName}${separator}${appName}';
126126
assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: '', appName: '', separator: { label: ' - ' } }), '');
127127
assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: '', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'Visual Studio Code');
128128
assert.strictEqual(labels.template(t, { dirty: '', activeEditorName: '', rootName: 'monaco', appName: 'Visual Studio Code', separator: { label: ' - ' } }), 'monaco - Visual Studio Code');

src/vs/workbench/electron-browser/main.contribution.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,16 @@ Note that there can still be cases where this setting is ignored (e.g. when usin
236236
},
237237
'window.title': {
238238
'type': 'string',
239-
'default': isMacintosh ? '$(activeEditorName)$(separator)$(rootName)' : '$(dirty)$(activeEditorName)$(separator)$(rootName)$(separator)$(appName)',
239+
'default': isMacintosh ? '${activeEditorName}${separator}${rootName}' : '${dirty}${activeEditorName}${separator}${rootName}${separator}${appName}',
240240
'description': nls.localize('title',
241241
`Controls the window title based on the active editor. Variables are substituted based on the context:
242-
$(activeEditorName): e.g. myFile.txt
243-
$(activeFilePath): e.g. /Users/Development/myProject/myFile.txt
244-
$(rootName): e.g. myProject
245-
$(rootPath): e.g. /Users/Development/myProject
246-
$(appName): e.g. VS Code
247-
$(dirty): a dirty indicator if the active editor is dirty
248-
$(separator): a conditional separator (" - ") that only shows when surrounded by variables with values`)
242+
\${activeEditorName}: e.g. myFile.txt
243+
\${activeFilePath}: e.g. /Users/Development/myProject/myFile.txt
244+
\${rootName}: e.g. myProject
245+
\${rootPath}: e.g. /Users/Development/myProject
246+
\${appName}: e.g. VS Code
247+
\${dirty}: a dirty indicator if the active editor is dirty
248+
\${separator}: a conditional separator (" - ") that only shows when surrounded by variables with values`)
249249
},
250250
'window.newWindowDimensions': {
251251
'type': 'string',

0 commit comments

Comments
 (0)