From 065f6a6a336ed1747d042b9967a69a9df329f613 Mon Sep 17 00:00:00 2001 From: Kristy Tian Date: Fri, 22 Sep 2023 16:03:35 -0700 Subject: [PATCH] feat:added filewatcher for pyproject.toml --- src/extension.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/extension.ts b/src/extension.ts index 3d29a99..0afa66b 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -13,6 +13,7 @@ import { createOutputChannel, onDidChangeConfiguration, registerCommand } from ' import { registerLanguageStatusItem, updateStatus } from './common/status'; let lsClient: LanguageClient | undefined; +let watcher: vscode.FileSystemWatcher | undefined; export async function activate(context: vscode.ExtensionContext): Promise { // This is required to get server name and module. This should be // the first thing that we do in this extension. @@ -44,6 +45,18 @@ export async function activate(context: vscode.ExtensionContext): Promise } }; + const workspaceFolder = vscode.workspace.workspaceFolders?.[0]; + + if (workspaceFolder) { + const fullPath = `${workspaceFolder.uri.fsPath}/pyproject.toml`; + watcher = vscode.workspace.createFileSystemWatcher(fullPath); + + watcher.onDidChange((uri) => { + console.log('pyproject.toml changed'); + vscode.commands.executeCommand('mypy-type-checker.restart', uri.fsPath); + }); + } + context.subscriptions.push( onDidChangePythonInterpreter(async () => { await runServer();