mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
Add new "files.defaultLanguage" configuration setting
This change adds a new configuration setting that sets the default language mode of new untitled files created with Ctrl+N (workbench.action.files.newUntitledFile). This activates the user's desired language mode when a new untitled file is created. Fixes #8729.
This commit is contained in:
@@ -32,6 +32,11 @@ export class SettingsDocument {
|
||||
return this.provideExcludeCompletionItems(location, range);
|
||||
}
|
||||
|
||||
// files.defaultLanguage
|
||||
if (location.path[0] === 'files.defaultLanguage') {
|
||||
return this.provideDefaultLanguageCompletionItems(location, range);
|
||||
}
|
||||
|
||||
return this.provideLanguageOverridesCompletionItems(location, position);
|
||||
}
|
||||
|
||||
@@ -192,6 +197,18 @@ export class SettingsDocument {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
|
||||
private provideDefaultLanguageCompletionItems(location: Location, range: vscode.Range): vscode.ProviderResult<vscode.CompletionItem[]> {
|
||||
// Suggestion model word matching includes a starting quote
|
||||
// Hence exclude it from the proposal range
|
||||
range = new vscode.Range(new vscode.Position(range.start.line, range.start.character + 1), range.end);
|
||||
|
||||
return vscode.languages.getLanguages().then(languages => {
|
||||
return languages.map(l => {
|
||||
return this.newSimpleCompletionItem(l, range, '', l + '"');
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private newSimpleCompletionItem(text: string, range: vscode.Range, description?: string, insertText?: string): vscode.CompletionItem {
|
||||
const item = new vscode.CompletionItem(text);
|
||||
item.kind = vscode.CompletionItemKind.Value;
|
||||
|
||||
Reference in New Issue
Block a user