Skip to content

Commit f6e380c

Browse files
committed
fix(langserver): support glob pattern in robot.tomls python-path setting
fixes #352
1 parent bd17a5d commit f6e380c

File tree

1 file changed

+8
-5
lines changed
  • packages/language_server/src/robotcode/language_server/robotframework

1 file changed

+8
-5
lines changed

packages/language_server/src/robotcode/language_server/robotframework/protocol.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import glob
12
import os
23
import sys
34
from dataclasses import dataclass, field
@@ -214,17 +215,18 @@ def on_robot_initialized(sender) -> None: ...
214215

215216
def server_initialized(self, sender: Any) -> None:
216217
for folder in self.workspace.workspace_folders:
217-
config: RobotConfig = self.workspace.get_configuration(RobotConfig, folder.uri)
218218

219219
for p in self.robot_profile.python_path or []:
220220
pa = Path(str(p))
221221
if not pa.is_absolute():
222222
pa = Path(folder.uri.to_path(), pa)
223223

224224
absolute_path = str(pa.absolute())
225-
if absolute_path not in sys.path:
226-
sys.path.insert(0, absolute_path)
225+
for f in glob.glob(absolute_path):
226+
if Path(f).is_dir() and f not in sys.path:
227+
sys.path.insert(0, f)
227228

229+
config: RobotConfig = self.workspace.get_configuration(RobotConfig, folder.uri)
228230
if config is not None:
229231
if config.env:
230232
for k, v in config.env.items():
@@ -237,7 +239,8 @@ def server_initialized(self, sender: Any) -> None:
237239
pa = Path(folder.uri.to_path(), pa)
238240

239241
absolute_path = str(pa.absolute())
240-
if absolute_path not in sys.path:
241-
sys.path.insert(0, absolute_path)
242+
for f in glob.glob(absolute_path):
243+
if Path(f).is_dir() and f not in sys.path:
244+
sys.path.insert(0, f)
242245

243246
self.on_robot_initialized(self)

0 commit comments

Comments
 (0)