Skip to content

Commit

Permalink
Merge branch 'initialized-sar'
Browse files Browse the repository at this point in the history
  • Loading branch information
GarstgerUnhold committed Oct 13, 2010
2 parents 930596b + 51e1e16 commit 69d6c40
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 5 deletions.
13 changes: 11 additions & 2 deletions plugins/document_search/features/replace.feature
Expand Up @@ -131,6 +131,15 @@ Feature: Replace in file
And I press "Replace" in the speedbar
Then the contents should be "foobar\nfoobar\nfoobar"
And the selection range should be from 14 to 20



Scenario: The Search-and-Replace Speedbar should get initialized with the currently selected text
When I replace the contents with "Foo\nBar\nFoo"
And I move the cursor to 0
And I select from 4 to 6
And I run the command DocumentSearch::SearchAndReplaceCommand
Then the "Search" field in the speedbar should have text "Bar"
And I type "Foo" into the "Replace" field in the speedbar
And I press "Replace" in the speedbar
Then the contents should be "Foo\nFoo\nFoo"


5 changes: 4 additions & 1 deletion plugins/document_search/lib/document_search.rb
Expand Up @@ -7,7 +7,7 @@ def self.menus
Redcar::Menu::Builder.build do
sub_menu "Edit" do
sub_menu "Search", :priority => 50 do
item "Document Search", SearchForwardCommand
item "Document Search", SearchForwardCommand
item "Repeat Last Search", RepeatPreviousSearchForwardCommand
item "Search and Replace", SearchAndReplaceCommand
end
Expand Down Expand Up @@ -89,6 +89,9 @@ def execute
class SearchAndReplaceCommand < Redcar::EditTabCommand
def execute
@speedbar = SearchAndReplaceSpeedbar.new
if doc.selection?
@speedbar.initial_query = doc.selected_text
end
win.open_speedbar(@speedbar)
end
end
Expand Down
Expand Up @@ -6,9 +6,12 @@ class << self
attr_accessor :previous_replace
attr_accessor :previous_search_type
end


attr_accessor :initial_query

def after_draw
self.query.value = SearchAndReplaceSpeedbar.previous_query || ""
SearchSpeedbar.previous_query ||= ""
self.query.value = @initial_query || SearchSpeedbar.previous_query
self.replace.value = SearchAndReplaceSpeedbar.previous_replace || ""
self.search_type.value = SearchAndReplaceSpeedbar.previous_search_type
self.query.edit_view.document.select_all
Expand Down

0 comments on commit 69d6c40

Please sign in to comment.