mirror of
https://github.com/Microsoft/vscode
synced 2024-10-06 03:17:00 +00:00
using json-parser to get existing recommendations
This commit is contained in:
parent
ba578c15de
commit
ebb5c05734
|
@ -6,7 +6,7 @@
|
|||
'use strict';
|
||||
|
||||
import * as vscode from 'vscode';
|
||||
import { getLocation, visit } from 'jsonc-parser';
|
||||
import { getLocation, visit, parse } from 'jsonc-parser';
|
||||
import * as path from 'path';
|
||||
import { SettingsDocument } from './settingsDocumentHelper';
|
||||
|
||||
|
@ -70,8 +70,9 @@ function registerExtensionsCompletions(): vscode.Disposable {
|
|||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
const range = document.getWordRangeAtPosition(position) || new vscode.Range(position, position);
|
||||
if (location.path[0] === 'recommendations') {
|
||||
const config = vscode.workspace && vscode.workspace.getConfiguration('extensions.json');
|
||||
const alreadyEnteredExtensions = config.get<string[]>('recommendations') || [];
|
||||
const config = parse(document.getText());
|
||||
const alreadyEnteredExtensions = config && config.recommendations || [];
|
||||
if (Array.isArray(alreadyEnteredExtensions)) {
|
||||
return vscode.extensions.all
|
||||
.filter(e => !(
|
||||
e.id.startsWith('vscode.')
|
||||
|
@ -80,6 +81,7 @@ function registerExtensionsCompletions(): vscode.Disposable {
|
|||
))
|
||||
.map(e => newSimpleCompletionItem(e.id, range, undefined, '"' + e.id + '"'));
|
||||
}
|
||||
}
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue