From 1326a2137d439a6aec0535f942e661f087f20d94 Mon Sep 17 00:00:00 2001 From: Dave Halter Date: Wed, 26 Nov 2014 02:31:35 +0100 Subject: [PATCH] Change the backwards tokenizer that keywords always stop. --- jedi/parser/user_context.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/jedi/parser/user_context.py b/jedi/parser/user_context.py index 387eb50c..d2baffc5 100644 --- a/jedi/parser/user_context.py +++ b/jedi/parser/user_context.py @@ -127,6 +127,10 @@ class UserContext(object): l = first_line if x == start_pos[0] else l start_cursor = x, len(l) - end[1] string += tok_str + if keyword.iskeyword(tok_str[::-1]): + # Keywords should always stop. The path will always end with + # them. + break last_type = tok_type # string can still contain spaces at the end