Skip to content

Commit

Permalink
Use document path only for completions (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
ccordoba12 authored Oct 29, 2020
1 parent 6c9aca4 commit 1425f75
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pyls/plugins/jedi_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def pyls_completions(config, document, position):
code_position = _utils.position_to_jedi_linecolumn(document, position)

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

if not completions:
return None
Expand Down
8 changes: 6 additions & 2 deletions pyls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def jedi_names(self, all_scopes=False, definitions=True, references=False):
references=references)

@lock
def jedi_script(self, position=None):
def jedi_script(self, position=None, use_document_path=False):
extra_paths = []
environment_path = None
env_vars = None
Expand All @@ -258,9 +258,13 @@ def jedi_script(self, position=None):
env_vars.pop('PYTHONPATH', None)

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

# Extend sys_path with document's path if requested
if use_document_path:
sys_path += [os.path.dirname(self.path)]

kwargs = {
'code': self.source,
'path': self.path,
Expand Down

0 comments on commit 1425f75

Please sign in to comment.