Skip to content

Commit 1425f75

Browse files
authored
Use document path only for completions (#881)
1 parent 6c9aca4 commit 1425f75

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

pyls/plugins/jedi_completion.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def pyls_completions(config, document, position):
5757
code_position = _utils.position_to_jedi_linecolumn(document, position)
5858

5959
code_position["fuzzy"] = settings.get("fuzzy", False)
60-
completions = document.jedi_script().complete(**code_position)
60+
completions = document.jedi_script(use_document_path=True).complete(**code_position)
6161

6262
if not completions:
6363
return None

pyls/workspace.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def jedi_names(self, all_scopes=False, definitions=True, references=False):
240240
references=references)
241241

242242
@lock
243-
def jedi_script(self, position=None):
243+
def jedi_script(self, position=None, use_document_path=False):
244244
extra_paths = []
245245
environment_path = None
246246
env_vars = None
@@ -258,9 +258,13 @@ def jedi_script(self, position=None):
258258
env_vars.pop('PYTHONPATH', None)
259259

260260
environment = self.get_enviroment(environment_path, env_vars=env_vars) if environment_path else None
261-
sys_path = self.sys_path(environment_path, env_vars=env_vars) + extra_paths + [os.path.dirname(self.path)]
261+
sys_path = self.sys_path(environment_path, env_vars=env_vars) + extra_paths
262262
project_path = self._workspace.root_path
263263

264+
# Extend sys_path with document's path if requested
265+
if use_document_path:
266+
sys_path += [os.path.dirname(self.path)]
267+
264268
kwargs = {
265269
'code': self.source,
266270
'path': self.path,

0 commit comments

Comments
 (0)