mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
Fixes for jsonc mode. Fixes #39199
This commit is contained in:
parent
936f4f6a90
commit
76989b38ff
|
@ -10,7 +10,7 @@
|
|||
"Other"
|
||||
],
|
||||
"activationEvents": [
|
||||
"onLanguage:json"
|
||||
"onLanguage:json", "onLanguage:jsonc"
|
||||
],
|
||||
"main": "./out/extension",
|
||||
"scripts": {
|
||||
|
|
|
@ -60,7 +60,7 @@ function registerKeybindingsCompletions(): vscode.Disposable {
|
|||
}
|
||||
|
||||
function registerSettingsCompletions(): vscode.Disposable {
|
||||
return vscode.languages.registerCompletionItemProvider({ language: 'json', pattern: '**/settings.json' }, {
|
||||
return vscode.languages.registerCompletionItemProvider({ language: 'jsonc', pattern: '**/settings.json' }, {
|
||||
provideCompletionItems(document, position, token) {
|
||||
return new SettingsDocument(document).provideCompletionItems(position, token);
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ function updateLaunchJsonDecorations(editor: vscode.TextEditor | undefined): voi
|
|||
editor.setDecorations(decoration, ranges);
|
||||
}
|
||||
|
||||
vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'json' }, {
|
||||
vscode.languages.registerDocumentSymbolProvider({ pattern: '**/launch.json', language: 'jsonc' }, {
|
||||
provideDocumentSymbols(document: vscode.TextDocument, token: vscode.CancellationToken): vscode.ProviderResult<vscode.SymbolInformation[]> {
|
||||
const result: vscode.SymbolInformation[] = [];
|
||||
let name: string = '';
|
||||
|
|
|
@ -56,7 +56,7 @@
|
|||
"filenames": [
|
||||
"settings.json",
|
||||
"launch.json",
|
||||
"debug.json",
|
||||
"tasks.json",
|
||||
"keybindings.json"
|
||||
],
|
||||
"configuration": "./language-configuration.json"
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
"dependencies": {
|
||||
"jsonc-parser": "^1.0.0",
|
||||
"request-light": "^0.2.1",
|
||||
"vscode-json-languageservice": "^3.0.2",
|
||||
"vscode-json-languageservice": "^3.0.3",
|
||||
"vscode-languageserver": "^3.5.0",
|
||||
"vscode-nls": "^2.0.2",
|
||||
"vscode-uri": "^1.0.1"
|
||||
|
|
|
@ -161,7 +161,7 @@ connection.onDidChangeConfiguration((change) => {
|
|||
let enableFormatter = settings && settings.json && settings.json.format && settings.json.format.enable;
|
||||
if (enableFormatter) {
|
||||
if (!formatterRegistration) {
|
||||
formatterRegistration = connection.client.register(DocumentRangeFormattingRequest.type, { documentSelector: [{ language: 'json' }] });
|
||||
formatterRegistration = connection.client.register(DocumentRangeFormattingRequest.type, { documentSelector: [{ language: 'json' }, { language: 'jsonc' }] });
|
||||
}
|
||||
} else if (formatterRegistration) {
|
||||
formatterRegistration.then(r => r.dispose());
|
||||
|
|
|
@ -52,9 +52,9 @@ request-light@^0.2.1:
|
|||
https-proxy-agent "^0.3.5"
|
||||
vscode-nls "^2.0.2"
|
||||
|
||||
vscode-json-languageservice@^3.0.2:
|
||||
version "3.0.2"
|
||||
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.0.2.tgz#66762127f24d32709ea5f410c58080ed8059d1e2"
|
||||
vscode-json-languageservice@^3.0.3:
|
||||
version "3.0.3"
|
||||
resolved "https://registry.yarnpkg.com/vscode-json-languageservice/-/vscode-json-languageservice-3.0.3.tgz#d865450a86dd3229bfac83a4245b38281e2dffb3"
|
||||
dependencies:
|
||||
jsonc-parser "^1.0.0"
|
||||
vscode-languageserver-types "^3.5.0"
|
||||
|
|
|
@ -55,6 +55,7 @@ export interface IJSONSchema {
|
|||
markdownEnumDescriptions?: string[]; // VSCode extension
|
||||
markdownDescription?: string; // VSCode extension
|
||||
doNotSuggest?: boolean; // VSCode extension
|
||||
allowComments?: boolean; // VSCode extension
|
||||
}
|
||||
|
||||
export interface IJSONSchemaMap {
|
||||
|
|
|
@ -379,7 +379,7 @@ export class ConfigurationManager implements IConfigurationManager {
|
|||
|
||||
public canSetBreakpointsIn(model: IModel): boolean {
|
||||
const modeId = model ? model.getLanguageIdentifier().language : null;
|
||||
if (!modeId || modeId === 'json') {
|
||||
if (!modeId || modeId === 'jsonc') {
|
||||
// do not allow breakpoints in our settings files
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -606,7 +606,7 @@ export class FeedbackWidgetRenderer extends Disposable {
|
|||
JSON.stringify(feedbackQuery, undefined, ' ') + '\n\n' +
|
||||
actualResultNames.map(name => `// ${name}: ${result.metadata.scoredResults[name]}`).join('\n');
|
||||
|
||||
this.editorService.openEditor({ contents, language: 'json' }, /*sideBySide=*/true).then(feedbackEditor => {
|
||||
this.editorService.openEditor({ contents, language: 'jsonc' }, /*sideBySide=*/true).then(feedbackEditor => {
|
||||
const sendFeedbackWidget = this._register(this.instantiationService.createInstance(FloatingClickWidget, feedbackEditor.getControl(), 'Send feedback', null));
|
||||
sendFeedbackWidget.render();
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
|||
if (this.isDefaultSettingsResource(uri) || this.isDefaultResourceSettingsResource(uri)) {
|
||||
|
||||
const scope = this.isDefaultSettingsResource(uri) ? ConfigurationScope.WINDOW : ConfigurationScope.RESOURCE;
|
||||
const mode = this.modeService.getOrCreateMode('json');
|
||||
const mode = this.modeService.getOrCreateMode('jsonc');
|
||||
const model = this._register(this.modelService.createModel('', mode, uri));
|
||||
|
||||
let defaultSettings: DefaultSettings;
|
||||
|
@ -139,14 +139,14 @@ export class PreferencesService extends Disposable implements IPreferencesServic
|
|||
|
||||
if (this.defaultSettingsRawResource.toString() === uri.toString()) {
|
||||
let defaultSettings: DefaultSettings = this.getDefaultSettings(ConfigurationScope.WINDOW);
|
||||
const mode = this.modeService.getOrCreateMode('json');
|
||||
const mode = this.modeService.getOrCreateMode('jsonc');
|
||||
const model = this._register(this.modelService.createModel(defaultSettings.raw, mode, uri));
|
||||
return TPromise.as(model);
|
||||
}
|
||||
|
||||
if (this.defaultKeybindingsResource.toString() === uri.toString()) {
|
||||
const defaultKeybindingsEditorModel = this.instantiationService.createInstance(DefaultKeybindingsEditorModel, uri);
|
||||
const mode = this.modeService.getOrCreateMode('json');
|
||||
const mode = this.modeService.getOrCreateMode('jsonc');
|
||||
const model = this._register(this.modelService.createModel(defaultKeybindingsEditorModel.content, mode, uri));
|
||||
return TPromise.as(model);
|
||||
}
|
||||
|
|
|
@ -125,7 +125,7 @@ export class PreferencesContribution implements IWorkbenchContribution {
|
|||
let schema = schemaRegistry.getSchemaContributions().schemas[uri.toString()];
|
||||
if (schema) {
|
||||
const modelContent = JSON.stringify(schema);
|
||||
const mode = this.modeService.getOrCreateMode('json');
|
||||
const mode = this.modeService.getOrCreateMode('jsonc');
|
||||
const model = this.modelService.createModel(modelContent, mode, uri);
|
||||
|
||||
let disposables = [];
|
||||
|
|
|
@ -210,6 +210,7 @@ export class Snippet {
|
|||
const schemaId = 'vscode://schemas/snippets';
|
||||
const schema: IJSONSchema = {
|
||||
'id': schemaId,
|
||||
'allowComments': true,
|
||||
'defaultSnippets': [{
|
||||
'label': nls.localize('snippetSchema.json.default', "Empty snippet"),
|
||||
'body': { '${1:snippetName}': { 'prefix': '${2:prefix}', 'body': '${3:snippet}', 'description': '${4:description}' } }
|
||||
|
|
|
@ -198,7 +198,7 @@ class GenerateColorThemeAction extends Action {
|
|||
colors: resultingColors,
|
||||
tokenColors: theme.tokenColors
|
||||
}, null, '\t');
|
||||
return this.editorService.openEditor({ contents, language: 'json' });
|
||||
return this.editorService.openEditor({ contents, language: 'jsonc' });
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue