From 4085aecb1d6f6a4772679f6954fe9ebc5658848f Mon Sep 17 00:00:00 2001 From: Julien Thewys Date: Sat, 9 Apr 2011 00:32:52 +0200 Subject: [PATCH] Fixes search endless loop when scrollback is negative. --- terminatorlib/searchbar.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/terminatorlib/searchbar.py b/terminatorlib/searchbar.py index 46b65900..dc9d08ce 100755 --- a/terminatorlib/searchbar.py +++ b/terminatorlib/searchbar.py @@ -127,7 +127,7 @@ class Searchbar(gtk.HBox): """Search forwards and jump to the next result, if any""" startrow,endrow = self.get_vte_buffer_range() while True: - if self.searchrow == endrow: + if self.searchrow >= endrow: self.searchrow = startrow self.reslabel.set_text(_('No more results')) return @@ -148,7 +148,7 @@ class Searchbar(gtk.HBox): """Jump back to the previous search""" startrow,endrow = self.get_vte_buffer_range() while True: - if self.searchrow == startrow: + if self.searchrow <= startrow: self.searchrow = endrow self.reslabel.set_text(_('No more results')) return @@ -177,7 +177,10 @@ class Searchbar(gtk.HBox): def get_vte_buffer_range(self): """Get the range of a vte widget""" column, endrow = self.vte.get_cursor_position() - startrow = max(0, endrow - self.config['scrollback_lines']) + if self.config['scrollback_lines'] < 0: + startrow = 0 + else: + startrow = max(0, endrow - self.config['scrollback_lines']) return(startrow, endrow) def end_search(self, widget=None):