Skip to content

Commit

Permalink
Switch default to case-insensitive filtering, and toggle it for searc…
Browse files Browse the repository at this point in the history
…h filters according to the original search
  • Loading branch information
Carey Underwood committed Nov 20, 2009
1 parent 523fcc0 commit be350cb
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions proper_editing.py
Expand Up @@ -20,6 +20,7 @@


import gedit import gedit
import gtk import gtk
import gtksourceview2


import re import re
import bisect import bisect
Expand Down Expand Up @@ -107,9 +108,10 @@ def fold(buffer):
class Actions(gedit.Plugin): class Actions(gedit.Plugin):
def Afold_from_search(self, action, window): def Afold_from_search(self, action, window):
view = window.get_active_view() view = window.get_active_view()
document = window.get_active_document()
buffer = view.get_buffer() buffer = view.get_buffer()


search, flags = buffer.get_search_text() search, flags = document.get_search_text()
if not search or search == window.get_data("SearchFold")['search']: if not search or search == window.get_data("SearchFold")['search']:
if weird.folded(buffer): if weird.folded(buffer):
return self.Aunfold(action, window) return self.Aunfold(action, window)
Expand All @@ -126,12 +128,17 @@ def Afold_from_search(self, action, window):


search, flags = buffer.get_text(left, right), 0 search, flags = buffer.get_text(left, right), 0


if flags & 0b100:
flags = 0
else:
flags = gtksourceview2.SEARCH_CASE_INSENSITIVE

window.set_data("SearchFold", {'search': search}) window.set_data("SearchFold", {'search': search})


start = buffer.get_start_iter() start = buffer.get_start_iter()
start.set_line_offset(0) start.set_line_offset(0)
while start: while start:
hit = start.forward_search(search, 0) hit = gtksourceview2.iter_forward_search(start, search, flags)
if hit: if hit:
hit[0].set_line_offset(0) hit[0].set_line_offset(0)
hit[1].forward_line() hit[1].forward_line()
Expand Down

0 comments on commit be350cb

Please sign in to comment.