refine completion provider for context keys, https://github.com/microsoft/vscode/issues/9303
This commit is contained in:
parent
29f80fb60f
commit
79f90304be
|
@ -147,17 +147,22 @@ function registerContextKeyCompletions(): vscode.Disposable {
|
||||||
{
|
{
|
||||||
async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) {
|
async provideCompletionItems(document: vscode.TextDocument, position: vscode.Position, token: vscode.CancellationToken) {
|
||||||
|
|
||||||
const replacing = document.getWordRangeAtPosition(position, /[\w.-\d]/);
|
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||||
const inserting = replacing?.with(undefined, position);
|
|
||||||
if (!replacing || !inserting) {
|
if (location.isAtPropertyKey) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
|
||||||
if (!location.matches(['*', 'when']) && !location.matches(['contributes', 'menus', '*', '*', 'when'])) {
|
if (!location.matches(['*', 'when']) && !location.matches(['contributes', 'menus', '*', '*', 'when'])) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const replacing = document.getWordRangeAtPosition(position, /[^"\s]+/);
|
||||||
|
if (!replacing) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const inserting = replacing.with(undefined, position);
|
||||||
|
|
||||||
const data = await vscode.commands.executeCommand<ContextKeyInfo[]>('getContextKeyInfo');
|
const data = await vscode.commands.executeCommand<ContextKeyInfo[]>('getContextKeyInfo');
|
||||||
if (token.isCancellationRequested || !data) {
|
if (token.isCancellationRequested || !data) {
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in a new issue