Skip to content
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

feat: added FileSystemWatcher for pyproject.toml #163

Closed
wants to merge 3 commits into from

Conversation

xytian315
Copy link

@xytian315 xytian315 commented Sep 22, 2023

Closes #122

@xytian315 xytian315 changed the title feat:added FileSystemWatcher for pyproject.toml feat: added FileSystemWatcher for pyproject.toml Sep 22, 2023
src/extension.ts Outdated
@@ -44,6 +45,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
};

const workspaceFolder = vscode.workspace.workspaceFolders?.[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You will need to do this on each of the workspace folders.

src/extension.ts Outdated

if (workspaceFolder) {
const fullPath = `${workspaceFolder.uri.fsPath}/pyproject.toml`;
watcher = vscode.workspace.createFileSystemWatcher(fullPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The watcher should be added to context.subscriptions so it can be disposed.

src/extension.ts Outdated

watcher.onDidChange((uri) => {
console.log('pyproject.toml changed');
vscode.commands.executeCommand('mypy-type-checker.restart', uri.fsPath);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can directly call the restart method that is available in this context.

Suggested change
vscode.commands.executeCommand('mypy-type-checker.restart', uri.fsPath);
await runServer();

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for suggestions. please check new commit.

@xytian315
Copy link
Author

@microsoft-github-policy-service agree

@karthiknadig karthiknadig self-assigned this Dec 14, 2023
@karthiknadig karthiknadig added the feature-request Request for new features or functionality label Dec 14, 2023
@karthiknadig
Copy link
Member

@xytian315 Sorry for the delayed response on this. I have refactored the code to be simpler for our case.

@karthiknadig karthiknadig force-pushed the 122-watch-pyproject branch from 24b2991 to c39f0d9 Compare July 29, 2024 16:13
@karthiknadig
Copy link
Member

Closing as stale, we can re-open this, if you want to continue working on this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Doesn't respond to changes to pyproject.toml
2 participants