Skip to content

Commit 22fee16

Browse files
committed
Move isConfigFile check to event handlers
1 parent 9419e41 commit 22fee16

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/extension.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,16 @@ export const activate = (context: vscode.ExtensionContext) => {
99

1010
context.subscriptions.push(
1111
vscode.workspace.onDidOpenTextDocument(document => {
12+
if (!isConfigFile(document)) {
13+
return;
14+
}
1215
updateDiagnostics(document, collection);
1316
})
1417
);
1518

1619
context.subscriptions.push(
1720
vscode.workspace.onDidChangeTextDocument(event => {
18-
if (event.document.getText() === '') {
21+
if (!isConfigFile(event.document)) {
1922
collection.delete(event.document.uri);
2023
return;
2124
}
@@ -49,10 +52,6 @@ const updateDiagnostics = (
4952

5053
const documentNode = parse(document.getText()) as parse.ObjectNode;
5154

52-
if (!isConfigFile(document)) {
53-
return;
54-
}
55-
5655
// check if urlsToWatch is empty
5756
const urlsToWatchNode = getASTNode(
5857
documentNode.children,

0 commit comments

Comments
 (0)