From d8d6b20a1749246ca0cbd1adfaccae75bd8ab5c0 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 9 Apr 2014 13:16:28 +0200 Subject: [PATCH] fix line split issues in cache --- jedi/cache.py | 3 +++ test/test_cache.py | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/jedi/cache.py b/jedi/cache.py index d815f43a..24959f19 100644 --- a/jedi/cache.py +++ b/jedi/cache.py @@ -101,6 +101,9 @@ def cache_call_signatures(source, user_pos, stmt): """This function calculates the cache key.""" index = user_pos[0] - 1 lines = source.splitlines() or [''] + if source and source[-1] == '\n': + lines.append('') + before_cursor = lines[index][:user_pos[1]] other_lines = lines[stmt.start_pos[0]:index] whole = '\n'.join(other_lines + [before_cursor]) diff --git a/test/test_cache.py b/test/test_cache.py index bbceb985..4ad437b0 100644 --- a/test/test_cache.py +++ b/test/test_cache.py @@ -99,3 +99,8 @@ def test_cache_call_signatures(): for i in range(3): check(8, 'int', 'boo') check(4, 'str', 'boo') + + +def test_cache_line_split_issues(): + """Should still work even if there's a newline.""" + assert jedi.Script('int(\n').call_signatures()[0].name == 'int'