Skip to content

Commit

Permalink
Simplify the file watchers
Browse files Browse the repository at this point in the history
It seems weird to have "special case worries" about files matching this pattern. Until I see the need with my own eyes, let's live without this.
  • Loading branch information
jennybc committed Nov 13, 2023
1 parent 59c1221 commit b8de55b
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions extensions/positron-r/src/testing/watcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,9 @@ async function createTestthatWatcher(
const pattern = new vscode.RelativePattern(workspaceFolder, testthatFilePattern);
const watcher = vscode.workspace.createFileSystemWatcher(pattern);

// Check that tests are not from RCMD and are not temp files
const RCMDpattern = '**/check/*.Rcheck/**';
const isValid = (uri: vscode.Uri) =>
match([uri.path], RCMDpattern).length === 0;

watcher.onDidCreate((uri) => (isValid(uri) ? getOrCreateFileItem(testingTools, uri) : undefined));
watcher.onDidChange((uri) =>
isValid(uri)
? parseTestsFromFile(testingTools, getOrCreateFileItem(testingTools, uri))
: undefined
);
watcher.onDidDelete((uri) =>
isValid(uri) ? testingTools.controller.items.delete(uri.path) : undefined
);
watcher.onDidCreate((uri) => getOrCreateFileItem(testingTools, uri));
watcher.onDidChange((uri) => parseTestsFromFile(testingTools, getOrCreateFileItem(testingTools, uri)));
watcher.onDidDelete((uri) => testingTools.controller.items.delete(uri.path));

return watcher;
}
Expand Down

0 comments on commit b8de55b

Please sign in to comment.