-
Notifications
You must be signed in to change notification settings - Fork 45
fix: bug Modified to trigger runServer when .black configuration file is updated #569 #571
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be just disposables of type Disposable[]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
onDidChange returns a Disposable so it should be added to disposables
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use async versions for FS apis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be:
return {
dispose: () => {disposables.forEach((d) => d.dispose())};
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you put it in context.subscriptions there is no need to explicitly dispose
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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