mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-26 19:44:25 +01:00
refine completion provider for context keys, https://github.com/microsoft/vscode/issues/9303
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user