Skip to content

Commit

Permalink
fix: additional paths shouldn't be duplicated every time a new sessio…
Browse files Browse the repository at this point in the history
…n starts (#120)
  • Loading branch information
jfcherng authored Jun 14, 2024
1 parent 9de78d5 commit 5c8e60f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions st3/lsp_utils/_client_handler/abstract_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,19 @@ def can_start(cls, window: sublime.Window, initiating_view: sublime.View,
@classmethod
def on_pre_start(cls, window: sublime.Window, initiating_view: sublime.View,
workspace_folders: List[WorkspaceFolder], configuration: ClientConfig) -> Optional[str]:
extra_paths = path.pathsep.join(cls.get_additional_paths())
extra_paths = cls.get_additional_paths()
if extra_paths:
original_path = configuration.env.get('PATH') or ''
if isinstance(original_path, list):
original_path = path.pathsep.join(original_path)
configuration.env['PATH'] = path.pathsep.join([extra_paths, original_path])
original_path_raw = configuration.env.get('PATH') or ''
if isinstance(original_path_raw, str):
original_paths = original_path_raw.split(path.pathsep)
else:
original_paths = original_path_raw
# To fix https://github.com/TerminalFi/LSP-copilot/issues/163 ,
# We don't want to add the same path multiple times whenever a new server session is created.
# Note that additional paths should be prepended to the original paths.
wanted_paths = [path for path in extra_paths if path not in original_paths]
wanted_paths.extend(original_paths)
configuration.env['PATH'] = path.pathsep.join(wanted_paths)
return None

# --- ClientHandlerInterface --------------------------------------------------------------------------------------
Expand Down

0 comments on commit 5c8e60f

Please sign in to comment.