fix: bug Modified to trigger runServer when .black configuration file is updated #569#571
fix: bug Modified to trigger runServer when .black configuration file is updated #569#571enumura1 wants to merge 5 commits intomicrosoft:mainfrom
Conversation
|
@enumura1 please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
src/common/utilities.ts
Outdated
| } | ||
|
|
||
| export function createConfigFileWatcher(onConfigChanged: () => Promise<void>): Disposable { | ||
| const watchers: FileSystemWatcher[] = []; |
There was a problem hiding this comment.
This should probably be just disposables of type Disposable[]
There was a problem hiding this comment.
Thank you for your review.
I've made the changes.
src/common/utilities.ts
Outdated
|
|
||
| const watcher = workspace.createFileSystemWatcher(pattern); | ||
|
|
||
| watcher.onDidChange(async () => { |
There was a problem hiding this comment.
onDidChange returns a Disposable so it should be added to disposables
There was a problem hiding this comment.
Thank you for your review.
I've made the changes.
src/common/utilities.ts
Outdated
| } | ||
|
|
||
| function watchConfigFile(filePath: string): void { | ||
| if (fs.existsSync(filePath)) { |
There was a problem hiding this comment.
Use async versions for FS apis.
There was a problem hiding this comment.
Thank you for your review.
I've made the changes.
| return { | ||
| dispose: () => { | ||
| for (const watcher of watchers) { | ||
| watcher.dispose(); | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
This should just be:
return {
dispose: () => {disposables.forEach((d) => d.dispose())};
}
There was a problem hiding this comment.
Thank you for your review.
I've made the changes.
src/extension.ts
Outdated
| configWatcherDisposable = createConfigFileWatcher(runServer); | ||
|
|
||
| context.subscriptions.push( | ||
| configWatcherDisposable, |
There was a problem hiding this comment.
You can call create config watcher here directly. Once you make it async be sure to add await.
There was a problem hiding this comment.
Thank you for your review.
I've modified the code to directly call createConfigFileWatcher in the subscriptions.push() method.
src/extension.ts
Outdated
| } | ||
|
|
||
| export async function deactivate(): Promise<void> { | ||
| if (configWatcherDisposable) { |
There was a problem hiding this comment.
If you put it in context.subscriptions there is no need to explicitly dispose
There was a problem hiding this comment.
Thank you for your review.
I've removed the explicit dispose()from the deactivate function.
|
hi @karthiknadig I would appreciate it if you can review the changes because I run into the same problems (and I don't like it 😅 ) |
Here are the changes:
Fixes #569