From 01daafa4b363e20b841cef36a2675ffec022e2df Mon Sep 17 00:00:00 2001 From: Idan Miara Date: Tue, 6 May 2025 23:56:42 +0300 Subject: [PATCH] LSP - call TPyLspClient.RestartServers when the PythonPath is changed (global or project) --- Source/cLSPClients.pas | 4 +++- Source/dmCommands.pas | 7 ++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Source/cLSPClients.pas b/Source/cLSPClients.pas index 00356d044..596ea9419 100644 --- a/Source/cLSPClients.pas +++ b/Source/cLSPClients.pas @@ -1061,12 +1061,14 @@ class procedure TPyLspClient.ProjectPythonPathChanged(const Sender: FProjectPythonPath := NewPath; - if (Length(Params.event.removed) > 0) or (Length(Params.event.added) > 0) then + if (Length(Params.event.removed) > 0) or (Length(Params.event.added) > 0) then begin for var Client in LspClients do if Client.Ready and Client.FLspClient.IsRequestSupported(lspDidChangeWorkspaceFolders) then Client.FLspClient.SendNotification(lspDidChangeWorkspaceFolders, Params); + RestartServers; + end; end; class procedure TPyLspClient.PythonVersionChanged(const Sender: TObject; const diff --git a/Source/dmCommands.pas b/Source/dmCommands.pas index 544ef9415..f6083ed72 100644 --- a/Source/dmCommands.pas +++ b/Source/dmCommands.pas @@ -1682,10 +1682,15 @@ procedure TCommandsDataModule.actPythonPathExecute(Sender: TObject); if not GI_PyControl.PythonLoaded then Exit; var Paths := TStringList.Create; + var PathsCurrent := TStringList.Create; try GI_PyControl.ActiveInterpreter.SysPathToStrings(Paths); + PathsCurrent.Assign(Paths); if EditFolderList(Paths, _('Python Path'), 870) then - GI_PyControl.ActiveInterpreter.StringsToSysPath(Paths); + if not PathsCurrent.Equals(Paths) then begin + GI_PyControl.ActiveInterpreter.StringsToSysPath(Paths); + TPyLspClient.RestartServers; + end; finally Paths.Free; end;