8000 Fix Jedi with large character (#201) · python-lsp/python-lsp-server@7dde7ca · GitHub
[go: up one dir, main page]

Skip to content

Commit 7dde7ca

Browse files
authored
Fix Jedi with large character (#201)
1 parent fbfb55a commit 7dde7ca

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

pyls/workspace.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,9 @@ def jedi_script(self, position=None):
264264
}
265265
if position:
266266
kwargs['line'] = position['line'] + 1
267-
kwargs['column'] = position['character']
267+
268+
# Normalise the position as per the LSP that accepts character positions > line length
269+
# https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md#position
270+
line_len = len(self.lines[position['line']])
271+
kwargs['column'] = min(position['character'], line_len - 1)
268272
return jedi.Script(**kwargs)

test/plugins/test_completion.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ def test_jedi_completion():
4040
assert len(items) > 0
4141
assert items[0]['label'] == 'isabs(s)'
4242

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

4447
def test_rope_completion():
4548
# Over 'i' in os.path.isabs(...)

0 commit comments

Comments
 (0)
0