Skip to content

Commit

Permalink
Fix Jedi with large character (#201)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatesn authored Dec 10, 2017
1 parent fbfb55a commit 7dde7ca
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pyls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,5 +264,9 @@ def jedi_script(self, position=None):
}
if position:
kwargs['line'] = position['line'] + 1
kwargs['column'] = position['character']

# Normalise the position as per the LSP that accepts character positions > line length
# https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position
line_len = len(self.lines[position['line']])
kwargs['column'] = min(position['character'], line_len - 1)
return jedi.Script(**kwargs)
3 changes: 3 additions & 0 deletions test/plugins/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ def test_jedi_completion():
assert len(items) > 0
assert items[0]['label'] == 'isabs(s)'

# Test we don't throw with big character
pyls_jedi_completions(doc, {'line': 1, 'character': 1000})


def test_rope_completion():
# Over 'i' in os.path.isabs(...)
Expand Down

0 comments on commit 7dde7ca

Please sign in to comment.