Skip to content

Commit

Permalink
feat:added filewatcher for pyproject.toml
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristy Tian authored and Kristy Tian committed Sep 22, 2023
1 parent 468eecb commit 065f6a6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<void> {
// This is required to get server name and module. This should be
// the first thing that we do in this extension.
Expand Down Expand Up @@ -44,6 +45,18 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
}
};

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();
Expand Down

0 comments on commit 065f6a6

Please sign in to comment.