mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 04:49:35 +00:00
fix #21177
This commit is contained in:
parent
28011c3662
commit
8e4e0a291a
|
@ -38,9 +38,9 @@ export class SettingsDocument {
|
|||
private provideWindowTitleCompletionItems(location: Location, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
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")));
|
||||
|
|
|
@ -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');
|
||||
});
|
||||
});
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue