mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
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) {
|
||||
|
||||
const replacing = document.getWordRangeAtPosition(position, /[\w.-\d]/);
|
||||
const inserting = replacing?.with(undefined, position);
|
||||
if (!replacing || !inserting) {
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
|
||||
if (location.isAtPropertyKey) {
|
||||
return;
|
||||
}
|
||||
|
||||
const location = getLocation(document.getText(), document.offsetAt(position));
|
||||
if (!location.matches(['*', 'when']) && !location.matches(['contributes', 'menus', '*', '*', 'when'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
const replacing = document.getWordRangeAtPosition(position, /[^"\s]+/);
|
||||
if (!replacing) {
|
||||
return;
|
||||
}
|
||||
const inserting = replacing.with(undefined, position);
|
||||
|
||||
const data = await vscode.commands.executeCommand<ContextKeyInfo[]>('getContextKeyInfo');
|
||||
if (token.isCancellationRequested || !data) {
|
||||
return;
|
||||
|
|
Loading…
Reference in a new issue