diff --git a/Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs b/Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs index 642f7059e0..b4f83f5179 100644 --- a/Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs +++ b/Python/Product/PythonTools/PythonTools/LanguageServerClient/PythonLanguageClient.cs @@ -31,6 +31,7 @@ using Microsoft.PythonTools.Project; using Microsoft.PythonTools.Utility; using Microsoft.VisualStudio.LanguageServer.Client; +using Microsoft.VisualStudio.LanguageServer.Protocol; using Microsoft.VisualStudio.Shell; using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Text; @@ -455,7 +456,6 @@ private LanguageServerSettings.PythonSettings GetSettings(Uri scopeUri = null) { } private void OnInterpreterChanged(object sender, EventArgs e) { - UpdateInterpreterExcludes(); OnSettingsChanged(sender, e); } @@ -475,7 +475,18 @@ private void OnAnalysisComplete(object sender, EventArgs e) { private void OnReanalyzeChanged(object sender, EventArgs e) { try { Debug.WriteLine("Reanalyze Changed"); - _deferredSettingsChangedTimer.Change(_defaultSettingsDelayMS, Timeout.Infinite); + + // Packages have changes, so send a workspace/didChangeWatchedFiles for the env directory. + this._clientContexts.ForEach(context => { + var createEvent = new FileEvent(); + createEvent.FileChangeType = FileChangeType.Changed; + createEvent.Uri = new Uri(CommonUtils.GetParent(context.InterpreterConfiguration.InterpreterPath)); + var didChangeParams = new DidChangeWatchedFilesParams(); + didChangeParams.Changes = new FileEvent[] { createEvent }; + _rpc.NotifyWithParameterObjectAsync(Methods.WorkspaceDidChangeWatchedFiles.Name, didChangeParams); + }); + + } catch (ObjectDisposedException) { } } @@ -524,24 +535,11 @@ private void OnWorkspaceFolderWatched(object sender, EventArgs e) { private void WatchedFilesRegistered(object sender, DidChangeWatchedFilesRegistrationOptions e) { // Add the file globs to our listener. It will listen to the globs - UpdateInterpreterExcludes(); _fileListener?.AddPatterns(e.Watchers); } - // By default Pylance will tell us to watch everything under the workspace with pattern "**/*" - // we can exclude the interpreter directory because we already have package managers listening to them - private void UpdateInterpreterExcludes() { - this._clientContexts.ForEach(context => { - if (PathUtils.IsSubpathOf(context.RootPath, context.InterpreterConfiguration.InterpreterPath)) { - var pattern = CommonUtils.GetRelativeFilePath(context.RootPath, context.InterpreterConfiguration.GetPrefixPath()).TrimEnd('\\') + "/**/*"; - var watcher = new FileSystemWatcher() { GlobPattern = pattern }; - this._fileListener.AddExclude(watcher); - } - - }); - } private void CreateClientContexts() { if (PythonWorkspaceContextProvider.Workspace != null) { diff --git a/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentFactoryProvider.cs b/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentFactoryProvider.cs index 7532bddea6..72ec9e486d 100644 --- a/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentFactoryProvider.cs +++ b/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentFactoryProvider.cs @@ -425,6 +425,7 @@ private static async Task CreateEnvironmentInfo(st var windowsInterpreterPath = Path.Combine(prefixPath, CondaEnvironmentFactoryConstants.WindowsExecutable); if (!File.Exists(interpreterPath)) { + Debug.WriteLine($"[CondaEnv] Python Interpreter not found for environment '{name}' (prefix: '{prefixPath}'). Expected at: {interpreterPath}"); return null; } diff --git a/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentManager.cs b/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentManager.cs index 45c5c46c27..12a2745ac3 100644 --- a/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentManager.cs +++ b/Python/Product/VSInterpreters/Interpreter/CondaEnvironmentManager.cs @@ -60,6 +60,7 @@ public static CondaEnvironmentManager Create(string condaPath) { return new CondaEnvironmentManager(condaPath); } + // Creates a new conda environment with the given name or path, installing the specified packages. 'conda create -n name python pkg1 pkg2 ... -y' public async Task CreateAsync(string newEnvNameOrPath, IEnumerable packageSpecs, ICondaEnvironmentManagerUI ui, CancellationToken ct) { bool success = false; using (await _working.LockAsync(ct)) { @@ -67,8 +68,8 @@ public async Task CreateAsync(string newEnvNameOrPath, IEnumerable s.FullSpec)); + "python", + }.Union(packageSpecs.Select(s => s.FullSpec)).Append("-y"); var operation = "conda " + string.Join(" ", args);