From 923e59b9c2e9d3bcc774f852031fccb75f21d45a Mon Sep 17 00:00:00 2001 From: David Halter Date: Thu, 21 Feb 2013 21:45:39 +0430 Subject: [PATCH] fixed position problems (with tokenizer offsets) --- jedi/common.py | 10 ++++++++-- jedi/parsing_representation.py | 1 - 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/jedi/common.py b/jedi/common.py index cddac5d3..35a10f62 100644 --- a/jedi/common.py +++ b/jedi/common.py @@ -63,6 +63,7 @@ class NoErrorTokenizer(object): self.stop_on_scope = stop_on_scope self.first_scope = False self.closed = False + self.first = True def push_last_back(self): self.gen.push_back(self.current) @@ -107,8 +108,13 @@ class NoErrorTokenizer(object): elif c[1] != '@': self.first_scope = True - c[2] = self.offset[0] + c[2][0], self.offset[1] + c[2][1] - c[3] = self.offset[0] + c[3][0], self.offset[1] + c[3][1] + if self.first: + c[2] = self.offset[0] + c[2][0], self.offset[1] + c[2][1] + c[3] = self.offset[0] + c[3][0], self.offset[1] + c[3][1] + self.first = False + else: + c[2] = self.offset[0] + c[2][0], c[2][1] + c[3] = self.offset[0] + c[3][0], c[3][1] return c diff --git a/jedi/parsing_representation.py b/jedi/parsing_representation.py index 200b60cf..a886b319 100644 --- a/jedi/parsing_representation.py +++ b/jedi/parsing_representation.py @@ -90,7 +90,6 @@ class Simple(Base): def __repr__(self): code = self.get_code().replace('\n', ' ') - # TODO (this todo doesn't belong here) positions are not added right. return "<%s: %s@%s,%s>" % \ (type(self).__name__, code, self.start_pos[0], self.start_pos[1])