improved error feedback and fix completion issue
This commit is contained in:
1 parent
a7846b54e5
commit
8454cc95f5
5 files changed
+26
-4
No files matched your search
@@ -37,7 +37,10 @@ export class EntityCompletionProvider implements vscode.CompletionItemProvider {
|
||||
const domain = dotMatch[1];
|
||||
const partial = dotMatch[2];
|
||||
if (this.cachedDomains.has(domain)) {
|
||||
const items = this.buildDomainItems(entities, domain, partial);
|
||||
// Range covers "domain.partial" so the full entity_id replaces it
|
||||
const replaceStart = position.translate(0, -(domain.length + 1 + partial.length));
|
||||
const replaceRange = new vscode.Range(replaceStart, position);
|
||||
const items = this.buildDomainItems(entities, domain, partial, replaceRange);
|
||||
if (items.length > 0) {
|
||||
return new vscode.CompletionList(items, false);
|
||||
}
|
||||
@@ -80,7 +83,8 @@ export class EntityCompletionProvider implements vscode.CompletionItemProvider {
|
||||
private buildDomainItems(
|
||||
entities: HAEntity[],
|
||||
domain: string,
|
||||
partial: string
|
||||
partial: string,
|
||||
replaceRange: vscode.Range
|
||||
): vscode.CompletionItem[] {
|
||||
const items: vscode.CompletionItem[] = [];
|
||||
const prefix = `${domain}.`;
|
||||
@@ -105,6 +109,7 @@ export class EntityCompletionProvider implements vscode.CompletionItemProvider {
|
||||
item.documentation = new vscode.MarkdownString(formatEntityMarkdown(entity));
|
||||
item.filterText = entity.entity_id;
|
||||
item.sortText = entity.entity_id;
|
||||
item.range = replaceRange;
|
||||
items.push(item);
|
||||
}
|
||||
return items;
|
||||
|
||||
Reference in new issue
Block a user