Files bigger than one MB (about 20kLOC) get cropped to avoid getting stuck completely

Fixes #843
This commit is contained in:
Dave Halter
2019-12-14 12:39:37 +01:00
parent 7639bc2da9
commit 3219f14c63
4 changed files with 38 additions and 8 deletions

View File

@@ -32,3 +32,20 @@ def test_additional_dynamic_modules(monkeypatch, Script):
['/foo/bar/jedi_not_existing_file.py']
)
assert not Script('def some_func(f):\n f.').completions()
def test_cropped_file_size(monkeypatch, names, Script):
code = 'class Foo(): pass\n'
monkeypatch.setattr(
settings,
'_cropped_file_size',
len(code)
)
foo, = names(code + code)
assert foo.line == 1
# It should just not crash if we are outside of the cropped range.
script = Script(code + code + 'Foo')
assert not script.goto_definitions()
assert 'Foo' in [c.name for c in script.completions()]