Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
allow FindNextRegex to wrap, have it do so by default
  • Loading branch information
rdp committed Feb 5, 2010
1 parent 10f5b64 commit 629afca
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions plugins/redcar/redcar.rb
@@ -1,4 +1,3 @@

module Redcar
module Top
class NewCommand < Command
Expand Down Expand Up @@ -434,7 +433,7 @@ def initialize(controller)
button :search, "Return" do
current_query = @speedbar.query
SearchForwardCommand::Speedbar.previous_query = current_query
FindNextRegex.new(Regexp.new(current_query), false).run
FindNextRegex.new(Regexp.new(current_query), true).run
end

end
Expand All @@ -444,10 +443,6 @@ def execute
win.open_speedbar(@speedbar)
end

def find query = @@previous_query
FindNextRegex.new(Regexp.new(query), false).run
end
attr_reader :speedbar
end

class RepeatPreviousSearchForwardCommand < Redcar::EditTabCommand
Expand All @@ -458,7 +453,7 @@ def execute
# open_bar.execute # Question: is there a way to programmatically
# pull up a bar (and execute it)? (the above line doesn't work)
# open_bar.speedbar.find
FindNextRegex.new(Regexp.new(SearchForwardCommand::Speedbar.previous_query), false).run
FindNextRegex.new(Regexp.new(SearchForwardCommand::Speedbar.previous_query), true).run
end

end
Expand Down Expand Up @@ -488,7 +483,7 @@ def execute
# next search the rest of the lines
line_num = doc.cursor_line + 1
curr_line = doc.get_line(line_num)
until line_num == doc.line_count or
until line_num == (doc.line_count - 1) or
found = (curr_line.to_s =~ @re)
line_num += 1
curr_line = doc.get_line(line_num)
Expand All @@ -500,7 +495,8 @@ def execute
doc.set_selection_range(startoff..endoff)
doc.scroll_to_line(line_num)
end
if !doc.get_line(line_num) and @wrap
if line_num == (doc.line_count - 1) and @wrap
@wrap = false
doc.cursor_offset = 0
execute
end
Expand Down Expand Up @@ -608,4 +604,4 @@ def self.start
Redcar::Project.start
end
end
end
end

0 comments on commit 629afca

Please sign in to comment.