Skip to content

Commit

Permalink
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@
"name": "vscode-home-assistant",
"displayName": "Home Assistant Config Helper",
"description": " Completion for entity-id's in Home Assistant Configurations",
"version": "0.1.6",
"version": "0.1.7",
"preview": true,
"engines": {
"vscode": "^1.32.0"
12 changes: 9 additions & 3 deletions src/entity-id-completion-provider.ts
Original file line number Diff line number Diff line change
@@ -4,7 +4,13 @@ import { HomeAssistant } from "./homeassistant";

export class EntityIdCompletionProvider implements vscode.CompletionItemProvider {

entityIdPropertyMatch = /(.*)entity_id(:)?( )?([-\w]+?)?$/;
propertyMatches = [
/(.*)entity_id(:)?( )?([-\w]+?)?$/,
/(.*)entity(:)?( )?([-\w]+?)?$/,
/(.*)entities(:)?( )?([-\w]+?)?$/,
/(.*)include_entities(:)?( )?([-\w]+?)?$/,
/(.*)exclude_entities(:)?( )?([-\w]+?)?$/
];

constructor(private ha: HomeAssistant) {
}
@@ -15,7 +21,7 @@ export class EntityIdCompletionProvider implements vscode.CompletionItemProvider
.lineAt(position)
.text.substr(0, position.character);

const isSingleLineMatch = linePrefix.match(this.entityIdPropertyMatch);
const isSingleLineMatch = this.propertyMatches.some(regex => regex.test(linePrefix));

if (!isSingleLineMatch && !this.isMultiLineMatch(document, position)) {
return [];
@@ -38,7 +44,7 @@ export class EntityIdCompletionProvider implements vscode.CompletionItemProvider
currentLine--;
continue;
}
return this.entityIdPropertyMatch.test(thisLine.text);
return this.propertyMatches.some(regex => regex.test(thisLine.text));
}
return false;
}

0 comments on commit c953045

Please sign in to comment.