When creating LS launch command from a list, quote args containing spaces

This commit is contained in:
Dominik Jain authored and Dominik Jain committed 2025-11-09 20:32:41 +01:00
1 parent 369d41b7f2
commit 12290821a0
2 files changed
+11 -2

No files matched your search

+2 -2
View File
@@ -33,7 +33,7 @@ from solidlsp.lsp_protocol_handler.server import (
make_request,
make_response,
)
from solidlsp.util.subprocess_util import subprocess_kwargs
from solidlsp.util.subprocess_util import quote_arg, subprocess_kwargs
log = logging.getLogger(__name__)
@@ -189,7 +189,7 @@ class SolidLanguageServerHandler:
if not isinstance(cmd, str) and not is_windows:
# Since we are using the shell, we need to convert the command list to a single string
# on Linux/macOS
cmd = " ".join(cmd)
cmd = " ".join(map(quote_arg, cmd))
log.info("Starting language server process via command: %s", self.process_launch_info.cmd)
kwargs = subprocess_kwargs()
kwargs["start_new_session"] = self.start_independent_lsp_process
+9
View File
@@ -11,3 +11,12 @@ def subprocess_kwargs():
if platform.system() == "Windows":
kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW # type: ignore
return kwargs
def quote_arg(arg: str) -> str:
"""
Adds quotes around an argument if it contains spaces.
"""
if " " not in arg:
return arg
return f'"{arg}"'