From 7a488ead2d2124b59a7d216d575d8e64b526828e Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 9 Jun 2016 04:06:28 +0300 Subject: [PATCH] scratchabit: Differentiate between next_line_addr() and next_addr(). I.e. "address of next line" and "next address after the address of current line". Due to the fact that serveral "virtual" lines may belong to the same physical address, they are not the same. --- scratchabit.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/scratchabit.py b/scratchabit.py index c665069..ded5d9c 100755 --- a/scratchabit.py +++ b/scratchabit.py @@ -171,12 +171,27 @@ class Editor(editor.EditorExt): line = self.get_cur_line() return line.ea - def next_addr(self): + # Address of the next line. It may be the same address as the + # current line, as several lines may "belong" to the same address, + # (virtual lines like headers, etc.) + def next_line_addr(self): try: return self.content[self.cur_line + 1].ea except: return None + # Return next address following the current line. May need to skip + # few virtual lines. + def next_addr(self): + addr = self.cur_addr() + n = self.cur_line + 1 + try: + while self.content[n].ea == addr: + n += 1 + return self.content[n].ea + except: + return None + def cur_addr_subno(self): line = self.get_cur_line() return (line.ea, line.subno) @@ -509,7 +524,7 @@ class Editor(editor.EditorExt): return addr = self.cur_addr() else: - addr = self.next_addr() + addr = self.next_line_addr() try: engine.render_from(TextSearchModel(self.search_str, self), addr, 10000000) -- 2.11.4.GIT