redcar 0.10 → 0.11.0dev

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/CHANGES +14 -0
  2. data/Rakefile +68 -29
  3. data/lib/redcar.rb +2 -2
  4. data/plugins/application/lib/application/dialogs/filter_list_dialog.rb +2 -1
  5. data/plugins/application_swt/spec/application_swt/gradient_spec.rb +3 -12
  6. data/plugins/core/lib/core/resource.rb +13 -5
  7. data/plugins/document_search/features/find.feature +366 -214
  8. data/plugins/document_search/features/incremental_search.feature +351 -0
  9. data/plugins/document_search/features/replace.feature +16 -16
  10. data/plugins/document_search/features/step_definitions/find_steps.rb +16 -0
  11. data/plugins/document_search/features/support/env.rb +11 -0
  12. data/plugins/document_search/lib/document_search.rb +149 -109
  13. data/plugins/document_search/lib/document_search/commands.rb +251 -202
  14. data/plugins/document_search/lib/document_search/find_speedbar.rb +138 -81
  15. data/plugins/document_search/lib/document_search/incremental_search_speedbar.rb +70 -0
  16. data/plugins/document_search/lib/document_search/query_options.rb +15 -39
  17. data/plugins/document_search/plugin.rb +1 -1
  18. data/plugins/edit_view/features/step_definitions/editing_steps.rb +6 -2
  19. data/plugins/edit_view_swt/lib/edit_view_swt.rb +2 -2
  20. data/plugins/file_parser/lib/file_parser.rb +6 -1
  21. data/plugins/html_view/features/step_definitions/web_view_steps.rb +12 -0
  22. data/plugins/html_view/features/support/env.rb +16 -0
  23. data/plugins/html_view/lib/html_view.rb +5 -1
  24. data/plugins/line_tools/lib/line_tools.rb +16 -0
  25. data/plugins/project/features/find_file.feature +28 -0
  26. data/plugins/project/features/open_and_save_files.feature +11 -0
  27. data/plugins/project/features/step_definitions/file_steps.rb +6 -1
  28. data/plugins/project/features/support/env.rb +2 -0
  29. data/plugins/project/lib/project.rb +49 -6
  30. data/plugins/project/lib/project/commands.rb +18 -6
  31. data/plugins/project/lib/project/find_file_dialog.rb +19 -8
  32. data/plugins/project/lib/project/find_recent_dialog.rb +30 -0
  33. data/plugins/project/lib/project/manager.rb +41 -10
  34. data/plugins/project/lib/project/recent.rb +64 -0
  35. data/plugins/project/spec/fixtures/myproject/vendor/bar.rb +0 -0
  36. data/plugins/project/spec/fixtures/myproject/vendor/plugins/bar.rb +0 -0
  37. data/plugins/{find-in-project → project_search}/TODO.md +3 -3
  38. data/plugins/project_search/features/support/env.rb +6 -0
  39. data/plugins/project_search/features/word_search.feature +34 -0
  40. data/plugins/project_search/lib/project_search.rb +73 -0
  41. data/plugins/project_search/lib/project_search/binary_data_detector.rb +46 -0
  42. data/plugins/project_search/lib/project_search/commands.rb +62 -0
  43. data/plugins/project_search/lib/project_search/hit.rb +17 -0
  44. data/plugins/{find-in-project/lib/find_in_project → project_search/lib/project_search}/images/collapsed.png +0 -0
  45. data/plugins/{find-in-project/lib/find_in_project → project_search/lib/project_search}/images/expanded.png +0 -0
  46. data/plugins/{find-in-project/lib/find_in_project → project_search/lib/project_search}/images/spinner.gif +0 -0
  47. data/plugins/project_search/lib/project_search/lucene_index.rb +64 -0
  48. data/plugins/project_search/lib/project_search/lucene_refresh.rb +22 -0
  49. data/plugins/project_search/lib/project_search/project.rb +14 -0
  50. data/plugins/project_search/lib/project_search/query.rb +29 -0
  51. data/plugins/{find-in-project/lib/find_in_project → project_search/lib/project_search}/stylesheets/style.css +14 -3
  52. data/plugins/project_search/lib/project_search/views/_file.html.erb +60 -0
  53. data/plugins/{find-in-project/lib/find_in_project → project_search/lib/project_search}/views/index.html.erb +12 -9
  54. data/plugins/project_search/lib/project_search/word_search.rb +105 -0
  55. data/plugins/project_search/lib/project_search/word_search_controller.rb +207 -0
  56. data/plugins/project_search/plugin.rb +8 -0
  57. data/plugins/project_search/spec/fixtures/project/binary_file.bin +0 -0
  58. data/plugins/project_search/spec/fixtures/project/foo.txt +43 -0
  59. data/plugins/project_search/spec/fixtures/project/qux.rb +3 -0
  60. data/plugins/project_search/spec/project_search/binary_data_detector_spec.rb +24 -0
  61. data/plugins/project_search/spec/project_search/word_search_spec.rb +157 -0
  62. data/plugins/project_search/spec/spec_helper.rb +27 -0
  63. data/plugins/redcar/redcar.rb +77 -71
  64. data/plugins/ruby/lib/ruby/syntax_checker.rb +1 -1
  65. data/plugins/snippets/features/snippets.feature +12 -0
  66. data/plugins/snippets/lib/snippets/tab_handler.rb +1 -1
  67. metadata +46 -25
  68. data/plugins/document_search/features/find_and_replace.feature +0 -723
  69. data/plugins/document_search/lib/document_search/find_and_replace_speedbar.rb +0 -142
  70. data/plugins/find-in-project/lib/find_in_project.rb +0 -35
  71. data/plugins/find-in-project/lib/find_in_project/commands.rb +0 -30
  72. data/plugins/find-in-project/lib/find_in_project/controllers.rb +0 -170
  73. data/plugins/find-in-project/lib/find_in_project/views/_divider.html.erb +0 -4
  74. data/plugins/find-in-project/lib/find_in_project/views/_file_heading.html.erb +0 -10
  75. data/plugins/find-in-project/lib/find_in_project/views/_file_line.html.erb +0 -6
  76. data/plugins/find-in-project/plugin.rb +0 -11
  77. data/plugins/project/lib/project/recent_directories.rb +0 -54
data/CHANGES CHANGED
@@ -1,3 +1,17 @@
1
+ Version 0.11 (TBA)
2
+ ==================
3
+
4
+ Enhancements:
5
+
6
+ * Fuzzy file finder now recognizes directories "a/c/repocontr" (Tim Felgentreff)
7
+ * Recent project fuzzy finder (Benedikt Müller)
8
+ * Improved DocumentSearch, with UI refinements, added Replace All commands (Tom Murray)
9
+ * Raise/lower region behaves better when you select multiple lines (Benedikt Müller)
10
+ * Project search backed by Lucene (Dan Lucraft)
11
+
12
+ Bugfixes:
13
+ * Fixed Unicode problems in DocumentSearch (Tom Murray)
14
+
1
15
  Version 0.10 (17 January 2011)
2
16
  ==============================
3
17
 
data/Rakefile CHANGED
@@ -1,4 +1,4 @@
1
- REDCAR_VERSION = "0.10" # also change in lib/redcar.rb!
1
+ REDCAR_VERSION = "0.11.0dev" # also change in lib/redcar.rb!
2
2
  require 'rubygems'
3
3
  require 'fileutils'
4
4
  require 'spec/rake/spectask'
@@ -41,43 +41,82 @@ task :release_docs do
41
41
  sh "rsync -e 'ssh -p #{port}' -avz doc/ danlucraft.com:#{docs_dir}/latest/"
42
42
  end
43
43
 
44
- ### CI
45
- COVERAGE_DATA = "coverage.data"
46
- task :ci do
47
- FileUtils.rm COVERAGE_DATA if File.exist?(COVERAGE_DATA)
48
- Rake::Task["specs_ci"].invoke
49
- Rake::Task["cucumber_ci"].invoke
44
+ def jruby_run(cmd)
45
+ opts = "-J-XstartOnFirstThread" if Config::CONFIG["host_os"] =~ /darwin/
46
+ sh("jruby --debug #{opts} -S #{cmd}; echo 'done'")
50
47
  end
51
48
 
52
- def find_ci_reporter(filename)
53
- jruby_gem_path = %x[jruby -rubygems -e "p Gem.path.first"].gsub("\n", "").gsub('"', "")
54
- result = Dir.glob("#{jruby_gem_path}/gems/ci_reporter-*/lib/ci/reporter/rake/#{filename}.rb").reverse.first
55
- result || raise("Could not find ci_reporter gem in #{jruby_gem_path}")
56
- end
49
+ ### CI
50
+ namespace :ci do
51
+ def rspec(options = "")
52
+ files = Dir['plugins/*/spec/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*/*_spec.rb']
53
+ rspec_opts = "#{options} -c #{files.join(" ")}"
54
+ "$GEM_HOME/bin/spec #{rspec_opts}"
55
+ end
57
56
 
58
- def rcov_run(cmd, opts)
59
- cmd = %{rcov --aggregate #{COVERAGE_DATA} -x "jsignal_internal,(erb),features/,spec/,vendor/,openssl/,yaml/,json/,yaml,gems,file:,(eval),(__FORWARDABLE__)" #{cmd} -- #{opts}}
60
- jruby_run(cmd)
61
- end
57
+ def cucumber(options = "")
58
+ "bin/cucumber #{options} plugins/*/features"
59
+ end
62
60
 
63
- def jruby_run(cmd)
64
- opts = "-J-XstartOnFirstThread" if Config::CONFIG["host_os"] =~ /darwin/
65
- sh("jruby --debug #{opts} -S #{cmd} && echo 'done'")
66
- end
61
+ namespace :rcov do
62
+ COVERAGE_DATA = "coverage.data"
67
63
 
68
- task :specs_ci do
69
- rspec_loader = find_ci_reporter "rspec_loader"
70
- files = Dir['plugins/*/spec/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*_spec.rb'] + Dir['plugins/*/spec/*/*/*/*_spec.rb']
71
- rspec_opts = "--require #{rspec_loader} --format CI::Reporter::RSpec -c #{files.join(" ")}"
72
- rcov_run('"$GEM_HOME"/bin/spec', rspec_opts)
64
+ def rcov_run(cmd, opts)
65
+ excluded_files = "jsignal_internal,(erb),features/,spec/,vendor/,openssl/,yaml/,json/,yaml,gems,file:,(eval),(__FORWARDABLE__)"
66
+ cmd = %{rcov --aggregate #{COVERAGE_DATA} -x "#{excluded_files}" #{cmd} -- #{opts}}
67
+ jruby_run(cmd)
68
+ end
69
+
70
+ desc "Run the coverage task for specs"
71
+ task :specs do
72
+ cmd = rspec
73
+ cmd, opts = cmd.split.first, cmd.split[1..-1].join(" ")
74
+ rcov_run(cmd, opts)
75
+ end
76
+
77
+ desc "Run the coverage task for features"
78
+ task :cucumber do
79
+ cmd = cucumber
80
+ cmd, opts = cmd.split.first, cmd.split[1..-1].join(" ")
81
+ rcov_run(cmd, opts)
82
+ end
83
+ end
84
+
85
+ desc "Run the coverage task"
86
+ task :rcov do
87
+ FileUtils.rm COVERAGE_DATA if File.exist?(COVERAGE_DATA)
88
+ Rake::Task["ci:rcov:specs"].invoke
89
+ Rake::Task["ci:rcov:cucumber"].invoke
90
+ end
91
+
92
+ def find_ci_reporter(filename)
93
+ jruby_gem_path = %x[jruby -rubygems -e "p Gem.path.first"].gsub("\n", "").gsub('"', "")
94
+ result = Dir.glob("#{jruby_gem_path}/gems/ci_reporter-*/lib/ci/reporter/rake/#{filename}.rb").reverse.first
95
+ result || raise("Could not find ci_reporter gem in #{jruby_gem_path}")
96
+ end
97
+
98
+ desc "Run the specs with JUnit output for the Hudson reporter"
99
+ task :specs do
100
+ rspec_loader = find_ci_reporter "rspec_loader"
101
+ rspec_opts = "--require #{rspec_loader} --format CI::Reporter::RSpec"
102
+ jruby_run(rspec(rspec_opts))
103
+ end
104
+
105
+ desc "Run the features with JUnit output for the Hudson reporter"
106
+ task :cucumber do
107
+ reports_folder = "features/reports"
108
+ FileUtils.rm_rf reports_folder if File.exist? reports_folder
109
+ jruby_run(cucumber("-f progress -f junit --out #{reports_folder}"))
110
+ end
73
111
  end
74
112
 
75
- task :cucumber_ci do
76
- reports_folder = "features/reports"
77
- FileUtils.rm_rf reports_folder if File.exist? reports_folder
78
- rcov_run("bin/cucumber", "-f progress -f junit --out #{reports_folder} plugins/*/features")
113
+ desc "Run specs and features with JUnit output"
114
+ task :ci do
115
+ Rake::Task["ci:specs"].invoke
116
+ Rake::Task["ci:cucumber"].invoke
79
117
  end
80
118
 
119
+
81
120
  ### TESTS
82
121
 
83
122
  desc "Run all specs and features"
@@ -51,9 +51,9 @@ end
51
51
  #
52
52
  # and so on.
53
53
  module Redcar
54
- VERSION = '0.10' # also change in the Rakefile!
54
+ VERSION = '0.11.0dev' # also change in the Rakefile!
55
55
  VERSION_MAJOR = 0
56
- VERSION_MINOR = 10
56
+ VERSION_MINOR = 11
57
57
  VERSION_RELEASE = 0
58
58
 
59
59
  ENVIRONMENTS = [:user, :debug, :test]
@@ -7,7 +7,7 @@ module Redcar
7
7
  class FilterListDialog
8
8
  include Redcar::Model
9
9
  include Redcar::Observable
10
-
10
+
11
11
  def initialize
12
12
  self.controller = Redcar.gui.controller_for(self).new(self)
13
13
  end
@@ -110,3 +110,4 @@ module Redcar
110
110
  end
111
111
  end
112
112
  end
113
+
@@ -124,19 +124,10 @@ describe Redcar::ApplicationSWT::Gradient do
124
124
  subject { Redcar::ApplicationSWT::Gradient.new( "black" ) }
125
125
 
126
126
  it "should return the SWT system color corresponding to that name" do
127
+ Redcar::ApplicationSWT.instance_variable_set("@display", Swt::Widgets::Display.current) if Redcar::ApplicationSWT.display.nil?
127
128
  subject.swt_colors[0].should == Redcar::ApplicationSWT.display.get_system_color(Swt::SWT::COLOR_BLACK)
128
129
  end
129
130
 
130
131
  end
131
-
132
- context "when constructed with the color 'none'" do
133
-
134
- subject { Redcar::ApplicationSWT::Gradient.new( "none" ) }
135
-
136
- it "should return the SWT system color corresponding to that name" do
137
- subject.swt_colors[0].should == Redcar::ApplicationSWT.display.get_system_color(Swt::SWT::NONE)
138
- end
139
-
140
- end
141
-
142
- end
132
+ end
133
+
@@ -3,6 +3,10 @@ module Redcar
3
3
  class Resource
4
4
  attr_reader :block, :task
5
5
 
6
+ class << self
7
+ attr_accessor :compute_synchronously
8
+ end
9
+
6
10
  def self.task_queue
7
11
  Redcar.app.task_queue
8
12
  end
@@ -44,11 +48,15 @@ module Redcar
44
48
  end
45
49
 
46
50
  def compute
47
- @mutex.synchronize do
48
- unless @task and @task.pending?
49
- @task = Resource::Task.new(self)
50
- @task.description = @description
51
- @future = Resource.task_queue.submit(@task)
51
+ if Resource.compute_synchronously
52
+ @value = block.call
53
+ else
54
+ @mutex.synchronize do
55
+ unless @task and @task.pending?
56
+ @task = Resource::Task.new(self)
57
+ @task.description = @description
58
+ @future = Resource.task_queue.submit(@task)
59
+ end
52
60
  end
53
61
  end
54
62
  end
@@ -1,78 +1,50 @@
1
- # Note: Because settings persist, even after the speedbar is closed, any setting changed in a
2
- # scenario will affect subsequent scenarios. To mitigate the chance of error, please inset a
3
- # "Current Settings" comment line after each scenario that changes settings.
4
- #
5
- # Because the Find speedbar and the find operations of the Find and Replace speedbar are supposed to
6
- # function identically, all scenarios here should be copied to find_and_replace.feature, with the
7
- # references to FindMenuCommand and FindSpeedbar adjusted accordingly.
8
-
9
1
  @speedbar
10
2
  Feature: Find
11
3
 
12
4
  Background:
13
5
  Given I open a new edit tab
14
6
 
7
+ # Begin: Scenarios adapted from incremental_search.feature
8
+
15
9
  Scenario: Open Find speedbar
16
10
  When I replace the contents with "Foo\nBar\nBaz"
17
11
  And I move the cursor to 0
18
- And I run the command DocumentSearch::FindMenuCommand
19
- Then the DocumentSearch::FindSpeedbar speedbar should be open
20
-
21
- Scenario: Change settings
22
- When I run the command DocumentSearch::FindMenuCommand
23
- And I choose "Plain" in the "query_type" field in the speedbar
24
- And I uncheck "Match case" in the speedbar
25
- And I check "Wrap around" in the speedbar
26
- Then "Plain" should be chosen in the "query_type" field in the speedbar
27
- And "Match case" should not be checked in the speedbar
28
- And "Wrap around" should be checked in the speedbar
29
-
30
- # Current Settings: Plain, No Match case, Wrap around
12
+ And I open the find speedbar
13
+ Then I should see the find speedbar
31
14
 
32
15
  Scenario: Search for a word should select next occurrence
33
16
  When I replace the contents with "Foo\nBar\nBaz"
34
17
  And I move the cursor to 0
35
- And I run the command DocumentSearch::FindMenuCommand
18
+ And I open the find speedbar
36
19
  And I type "Bar" into the "Find" field in the speedbar
20
+ And I press "Next" in the speedbar
37
21
  Then the selected text should be "Bar"
38
22
 
39
23
  Scenario: Search twice should move to the next occurrence
40
24
  When I replace the contents with "Foo\nBar\nFoo"
41
25
  And I move the cursor to 0
42
- And I run the command DocumentSearch::FindMenuCommand
26
+ And I open the find speedbar
43
27
  And I type "Foo" into the "Find" field in the speedbar
28
+ And I press "Next" in the speedbar
44
29
  Then the selection should be on line 0
45
30
  When I press "Next" in the speedbar
46
31
  Then the selected text should be "Foo"
47
32
  And the selection should be on line 2
48
33
 
49
- Scenario: Search should incrementally update
50
- When I replace the contents with "Foo\nBaar\nBaaz"
51
- And I move the cursor to 0
52
- And I run the command DocumentSearch::FindMenuCommand
53
- And I type "Ba" into the "Find" field in the speedbar
54
- Then the selected text should be "Ba"
55
- And the selection should be on line 1
56
- When I type "Baa" into the "Find" field in the speedbar
57
- And the selection should be on line 1
58
- When I type "Baaz" into the "Find" field in the speedbar
59
- Then the selected text should be "Baaz"
60
- And the selection should be on line 2
61
- When I type "Baa" into the "Find" field in the speedbar
62
- Then the selection should be on line 2
63
-
64
34
  Scenario: Search for a word adjacent to cursor should select word
65
35
  When I replace the contents with "Foo\nBar\nBaz"
66
36
  And I move the cursor to 0
67
- And I run the command DocumentSearch::FindMenuCommand
37
+ And I open the find speedbar
68
38
  And I type "Foo" into the "Find" field in the speedbar
39
+ And I press "Next" in the speedbar
69
40
  Then the selected text should be "Foo"
70
41
 
71
42
  Scenario: Search for a word should find occurrence after the cursor
72
43
  When I replace the contents with "Foo\nBar\nBaz\nFoo"
73
44
  And I move the cursor to 1
74
- And I run the command DocumentSearch::FindMenuCommand
45
+ And I open the find speedbar
75
46
  And I type "Foo" into the "Find" field in the speedbar
47
+ And I press "Next" in the speedbar
76
48
  Then the selection should be on line 3
77
49
  And the selected text should be "Foo"
78
50
  When I press "Next" in the speedbar
@@ -81,145 +53,190 @@ Feature: Find
81
53
 
82
54
  Scenario: Search for a word should wrap to earlier occurrence if none left
83
55
  When I replace the contents with "Foo\nBar\nBaz"
84
- And I move the cursor to 1
85
- And I run the command DocumentSearch::FindMenuCommand
56
+ And I move the cursor to 3
57
+ And I open the find speedbar
86
58
  And I type "Foo" into the "Find" field in the speedbar
59
+ And I press "Next" in the speedbar
87
60
  Then the selected text should be "Foo"
88
61
  And the selection should be on line 0
89
62
 
90
- Scenario: Doesn't search for a regex
91
- When I replace the contents with "Foo\nBar\nBaz"
63
+ Scenario: Should start searching after the selection if the query matches exactly
64
+ When I replace the contents with "Foobar\nBarfoo\nBazhmm\nFoobar"
65
+ And I select from 0 to 6
66
+ And I open the find speedbar
67
+ And I type "Foobar" into the "Find" field in the speedbar
68
+ And I press "Next" in the speedbar
69
+ Then the selected text should be "Foobar"
70
+ And the selection should be on line 3
71
+
72
+ Scenario: Should start search within the selection if it matches the beginning of the query
73
+ When I replace the contents with "Foobar\nBarfoo\nBazhmm\nFoobar"
74
+ And I select from 0 to 3
75
+ And I open the find speedbar
76
+ And I type "Foobar" into the "Find" field in the speedbar
77
+ And I press "Next" in the speedbar
78
+ Then the selected text should be "Foobar"
79
+ And the selection range should be from 0 to 6
80
+
81
+ Scenario: Should start search within the selection if the query matches partially
82
+ When I replace the contents with "Foobar\nBarfoo\nBazhmm\nFoobar"
83
+ And I select from 0 to 6
84
+ And I open the find speedbar
85
+ And I type "Foo" into the "Find" field in the speedbar
86
+ And I press "Next" in the speedbar
87
+ Then the selected text should be "Foo"
88
+ And the selection range should be from 0 to 3
89
+
90
+ Scenario: Not thrown off by multi-byte characters
91
+ When I replace the contents with "Benedikt Müller"
92
92
  And I move the cursor to 0
93
- And I run the command DocumentSearch::FindMenuCommand
94
- And I type "Ba." into the "Find" field in the speedbar
95
- Then there should not be any text selected
93
+ And I open the find speedbar
94
+ And I type "ler" into the "Find" field in the speedbar
95
+ And I press "Next" in the speedbar
96
+ Then the selected text should be "ler"
97
+ And the selection range should be from 12 to 15
96
98
 
97
- Scenario: Search for a regex
98
- When I replace the contents with "Foo\nBar\nBaz"
99
+ Scenario: Not thrown off by multi-byte characters 2
100
+ When I replace the contents with "Benedikt Müller\n foo "
99
101
  And I move the cursor to 0
100
- And I run the command DocumentSearch::FindMenuCommand
101
- And I type "Ba." into the "Find" field in the speedbar
102
- And I choose "Regex" in the "query_type" field in the speedbar
103
- Then the selected text should be "Bar"
104
- When I press "Next" in the speedbar
105
- Then the selected text should be "Baz"
102
+ And I open the find speedbar
103
+ And I type "foo" into the "Find" field in the speedbar
104
+ And I press "Next" in the speedbar
105
+ Then the selected text should be "foo"
106
+ And the selection range should be from 17 to 20
106
107
 
107
- # Current Settings: Regex, No Match case, Wrap around
108
+ Scenario: Not thrown off by multi-byte characters 3
109
+ When I replace the contents with "你好, 凯兰\nYou make my heart super happy."
110
+ And I move the cursor to 0
111
+ And I open the find speedbar
112
+ And I type "you" into the "Find" field in the speedbar
113
+ And I press "Next" in the speedbar
114
+ Then the selected text should be "You"
115
+ And the selection range should be from 7 to 10
108
116
 
109
- Scenario: Search for a regex matches a second time
110
- When I replace the contents with "Foo\nBar\nBaz"
117
+ Scenario: Handles repeated search across by multi-byte characters
118
+ When I replace the contents with "Foo\n你好, 凯兰\nFoo\nBar\nFoo\nBaz"
111
119
  And I move the cursor to 0
112
- And I run the command DocumentSearch::FindMenuCommand
113
- And I type "Ba." into the "Find" field in the speedbar
114
- Then the selected text should be "Bar"
120
+ And I open the find speedbar
121
+ And I type "foo" into the "Find" field in the speedbar
122
+ And I press "Next" in the speedbar
123
+ Then the selected text should be "Foo"
124
+ And the selection should be on line 0
115
125
  When I press "Next" in the speedbar
116
- Then the selected text should be "Baz"
126
+ Then the selected text should be "Foo"
127
+ And the selection should be on line 2
128
+ When I press "Next" in the speedbar
129
+ Then the selected text should be "Foo"
130
+ And the selection should be on line 4
131
+ When I press "Next" in the speedbar
132
+ Then the selected text should be "Foo"
133
+ And the selection should be on line 0
134
+ When I press "Next" in the speedbar
135
+ Then the selected text should be "Foo"
136
+ And the selection should be on line 2
137
+
138
+ Scenario: Should select multi-byte characters
139
+ When I replace the contents with "Benedikt Müller"
140
+ And I move the cursor to 0
141
+ And I open the find speedbar
142
+ And I type "mül" into the "Find" field in the speedbar
143
+ And I press "Next" in the speedbar
144
+ Then the selected text should be "Mül"
145
+ And the selection range should be from 9 to 12
146
+
147
+ Scenario: Should select multi-byte characters
148
+ When I replace the contents with "Benedikt Müller"
149
+ And I move the cursor to 0
150
+ And I open the find speedbar
151
+ And I type "mül" into the "Find" field in the speedbar
152
+ And I press "Next" in the speedbar
153
+ Then the selected text should be "Mül"
154
+ And the selection range should be from 9 to 12
155
+
156
+ Scenario: Should select multi-byte characters 2
157
+ When I replace the contents with "你好, 凯兰\nYou make my heart super happy."
158
+ And I move the cursor to 0
159
+ And I open the find speedbar
160
+ And I type "凯兰" into the "Find" field in the speedbar
161
+ And I press "Next" in the speedbar
162
+ Then the selected text should be "凯兰"
163
+ And the selection range should be from 4 to 6
117
164
 
118
- Scenario: Doesn't search for a glob
165
+ Scenario: Doesn't search for a regex
119
166
  When I replace the contents with "Foo\nBar\nBaz"
120
167
  And I move the cursor to 0
121
- And I run the command DocumentSearch::FindMenuCommand
122
- And I choose "Plain" in the "query_type" field in the speedbar
123
- And I type "Ba*" into the "Find" field in the speedbar
168
+ And I open the find speedbar
169
+ And I type "Ba." into the "Find" field in the speedbar
170
+ And I press "Next" in the speedbar
124
171
  Then there should not be any text selected
125
172
 
126
- Scenario: Search for a glob
127
- When I replace the contents with "Foo\nBar none I said\nBaz"
173
+ Scenario: Search for a regex
174
+ When I replace the contents with "Foo\nBar\nBaz"
128
175
  And I move the cursor to 0
129
- And I run the command DocumentSearch::FindMenuCommand
130
- And I type "Ba*" into the "Find" field in the speedbar
131
- And I choose "Glob" in the "query_type" field in the speedbar
132
- Then the selected text should be "Bar none I said"
176
+ And I open the find speedbar
177
+ And I type "Ba." into the "Find" field in the speedbar
178
+ And I press "Next" in the speedbar
179
+ Then there should not be any text selected
180
+ When I check "Regex" in the speedbar
181
+ And I press "Next" in the speedbar
182
+ Then the selected text should be "Bar"
133
183
  When I press "Next" in the speedbar
134
184
  Then the selected text should be "Baz"
135
185
 
136
- # Current Settings: Glob, No Match case, Wrap around
137
-
138
- Scenario: Should not match case if unset
186
+ Scenario: Should not match case by default
139
187
  When I replace the contents with "Foo\nBar\nBaz"
140
188
  And I move the cursor to 0
141
- And I run the command DocumentSearch::FindMenuCommand
142
- And I choose "Plain" in the "query_type" field in the speedbar
189
+ And I open the find speedbar
143
190
  And I type "foo" into the "Find" field in the speedbar
191
+ And I press "Next" in the speedbar
144
192
  Then the selected text should be "Foo"
145
193
 
146
- # Current Settings: Plain, No Match case, Wrap around
147
-
148
- Scenario: Should not match case if unset with regex
194
+ Scenario: Should not match case with regex by default
149
195
  When I replace the contents with "Foo\nBar\nBaz"
150
196
  And I move the cursor to 0
151
- And I run the command DocumentSearch::FindMenuCommand
152
- And I choose "Regex" in the "query_type" field in the speedbar
197
+ And I open the find speedbar
153
198
  And I type "fo." into the "Find" field in the speedbar
199
+ And I press "Next" in the speedbar
200
+ Then there should not be any text selected
201
+ When I check "Regex" in the speedbar
202
+ And I press "Next" in the speedbar
154
203
  Then the selected text should be "Foo"
155
204
 
156
- # Current Settings: Regex, No Match case, Wrap around
157
-
158
- Scenario: Should not match case if unset with glob
159
- When I replace the contents with "Foo\nBar\nBaz"
160
- And I move the cursor to 0
161
- And I run the command DocumentSearch::FindMenuCommand
162
- And I choose "Glob" in the "query_type" field in the speedbar
163
- And I type "fo*" into the "Find" field in the speedbar
164
- Then the selected text should be "Foo"
165
-
166
- # Current Settings: Glob, No Match case, Wrap around
167
-
168
205
  Scenario: Should match case if requested
169
206
  When I replace the contents with "Foo\nBar\nBaz"
170
207
  And I move the cursor to 0
171
- And I run the command DocumentSearch::FindMenuCommand
172
- And I choose "Plain" in the "query_type" field in the speedbar
173
- And I uncheck "Match case" in the speedbar
208
+ And I open the find speedbar
174
209
  And I type "foo" into the "Find" field in the speedbar
210
+ And I press "Next" in the speedbar
175
211
  Then the selected text should be "Foo"
176
212
  When I check "Match case" in the speedbar
213
+ And I move the cursor to 0
214
+ And I press "Next" in the speedbar
177
215
  Then there should not be any text selected
178
-
179
- # Current Settings: Plain, Match case, Wrap around
216
+ When I type "Foo" into the "Find" field in the speedbar
217
+ And I move the cursor to 0
218
+ And I press "Next" in the speedbar
219
+ Then the selected text should be "Foo"
180
220
 
181
221
  Scenario: Should match case if requested with regex
182
222
  When I replace the contents with "Foo\nBar\nBaz"
183
223
  And I move the cursor to 0
184
- And I run the command DocumentSearch::FindMenuCommand
185
- And I choose "Regex" in the "query_type" field in the speedbar
186
- And I uncheck "Match case" in the speedbar
224
+ And I open the find speedbar
225
+ And I check "Regex" in the speedbar
187
226
  And I type "fo." into the "Find" field in the speedbar
227
+ And I press "Next" in the speedbar
188
228
  Then the selected text should be "Foo"
189
229
  When I check "Match case" in the speedbar
190
- Then there should not be any text selected
191
-
192
- # Current Settings: Regex, Match case, Wrap around
193
-
194
- Scenario: Should match case if requested with glob
195
- When I replace the contents with "Foo\nBar\nBaz"
196
230
  And I move the cursor to 0
197
- And I run the command DocumentSearch::FindMenuCommand
198
- And I choose "Glob" in the "query_type" field in the speedbar
199
- And I uncheck "Match case" in the speedbar
200
- And I type "fo*" into the "Find" field in the speedbar
201
- Then the selected text should be "Foo"
202
- When I check "Match case" in the speedbar
231
+ And I press "Next" in the speedbar
203
232
  Then there should not be any text selected
204
233
 
205
- # Current Settings: Glob, Match case, Wrap around
206
-
207
- Scenario: Reset settings
208
- When I run the command DocumentSearch::FindMenuCommand
209
- And I choose "Plain" in the "query_type" field in the speedbar
210
- And I uncheck "Match case" in the speedbar
211
- And I check "Wrap around" in the speedbar
212
- Then "Plain" should be chosen in the "query_type" field in the speedbar
213
- And "Match case" should not be checked in the speedbar
214
- And "Wrap around" should be checked in the speedbar
215
-
216
- # Current Settings: Plain, No Match case, Wrap around
217
-
218
234
  Scenario: Find next with wrap around
219
235
  When I replace the contents with "Foo\nBar Foo\nHmm\nBaz"
220
236
  And I move the cursor to 0
221
- And I run the command DocumentSearch::FindMenuCommand
237
+ And I open the find speedbar
222
238
  And I type "Foo" into the "Find" field in the speedbar
239
+ And I press "Next" in the speedbar
223
240
  Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
224
241
  And the selected text should be "Foo"
225
242
  And the selection range should be from 0 to 3
@@ -235,9 +252,10 @@ Feature: Find
235
252
  Scenario: Find next without wrap around
236
253
  When I replace the contents with "Foo\nBar Foo\nHmm\nBaz"
237
254
  And I move the cursor to 0
238
- And I run the command DocumentSearch::FindAndReplaceSpeedbarCommand
255
+ And I open the find speedbar
239
256
  And I uncheck "Wrap around" in the speedbar
240
- And I type "Foo" into the "Find" field in the speedbar
257
+ And I type "foo" into the "Find" field in the speedbar
258
+ And I press "Next" in the speedbar
241
259
  Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
242
260
  And the selected text should be "Foo"
243
261
  And the selection range should be from 0 to 3
@@ -249,35 +267,28 @@ Feature: Find
249
267
  Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
250
268
  And there should not be any text selected
251
269
 
252
- # Current Settings: Plain, No Match case, No Wrap around
253
-
254
- Scenario: Find previous with wrap around
270
+ Scenario: Find previous with wrap around by default
255
271
  When I replace the contents with "Foo\nBar Foo\nHmm\nBaz"
256
272
  And I move the cursor to 18
257
- And I run the command DocumentSearch::FindAndReplaceSpeedbarCommand
258
- And I type "Foo" into the "Find" field in the speedbar
259
- Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
260
- And there should not be any text selected
273
+ And I open the find speedbar
274
+ And I type "foo" into the "Find" field in the speedbar
275
+ And I press "Next" in the speedbar
276
+ Then the selected text should be "Foo"
277
+ And the selection range should be from 0 to 3
261
278
  When I press "Previous" in the speedbar
262
- Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
263
- And the selected text should be "Foo"
279
+ Then the selected text should be "Foo"
264
280
  And the selection range should be from 8 to 11
265
281
  When I press "Previous" in the speedbar
266
- Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
267
- And the selected text should be "Foo"
282
+ Then the selected text should be "Foo"
268
283
  And the selection range should be from 0 to 3
269
- When I check "Wrap around" in the speedbar
270
- And I press "Previous" in the speedbar
271
- Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
272
- And the selected text should be "Foo"
284
+ When I press "Previous" in the speedbar
285
+ Then the selected text should be "Foo"
273
286
  And the selection range should be from 8 to 11
274
287
 
275
- # Current Settings: Plain, No Match case, Wrap around
276
-
277
288
  Scenario: Find previous without wrap around
278
289
  When I replace the contents with "Foo\nBar Foo\nHmm\nBaz"
279
290
  And I move the cursor to 18
280
- And I run the command DocumentSearch::FindAndReplaceSpeedbarCommand
291
+ And I open the find speedbar
281
292
  And I uncheck "Wrap around" in the speedbar
282
293
  And I type "Foo" into the "Find" field in the speedbar
283
294
  Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
@@ -294,96 +305,237 @@ Feature: Find
294
305
  Then the contents should be "Foo\nBar Foo\nHmm\nBaz"
295
306
  And there should not be any text selected
296
307
 
297
- # Current Settings: Plain, No Match case, No Wrap around
298
-
299
308
  Scenario: Should scroll vertically to the match
300
309
  When I replace the contents with 100 lines of "xxx" then "Foo"
301
310
  And I scroll to the top of the document
302
311
  And I move the cursor to 0
303
- And I run the command DocumentSearch::FindMenuCommand
304
- And I type "Foo" into the "Find" field in the speedbar
312
+ And I open the find speedbar
313
+ And I type "foo" into the "Find" field in the speedbar
314
+ And I press "Next" in the speedbar
305
315
  Then the selected text should be "Foo"
306
316
  And line number 100 should be visible
307
317
 
308
318
  Scenario: "Should scroll horizontally to the match"
309
319
  When I replace the contents with 300 "x" then "Foo"
310
320
  And I move the cursor to 0
311
- And I run the command DocumentSearch::FindMenuCommand
312
- And I type "Foo" into the "Find" field in the speedbar
321
+ And I open the find speedbar
322
+ And I type "foo" into the "Find" field in the speedbar
323
+ And I press "Next" in the speedbar
313
324
  Then the selected text should be "Foo"
314
325
  And horizontal offset 302 should be visible
315
326
 
316
327
  Scenario: Should reopen with the same text as the previous search
317
- When I run the command DocumentSearch::FindMenuCommand
328
+ When I open the find speedbar
318
329
  And I type "foo" into the "Find" field in the speedbar
319
330
  And I close the speedbar
320
- And I run the command DocumentSearch::FindMenuCommand
331
+ And I open the find speedbar
321
332
  Then the "Find" field in the speedbar should have text "foo"
322
333
 
323
- Scenario: Should reopen with the same value of query type as the previous search
324
- When I run the command DocumentSearch::FindMenuCommand
325
- And I choose "Plain" in the "query_type" field in the speedbar
326
- And I close the speedbar
327
- And I run the command DocumentSearch::FindMenuCommand
328
- Then "Plain" should be chosen in the "query_type" field in the speedbar
329
- When I choose "Regex" in the "query_type" field in the speedbar
330
- And I close the speedbar
331
- And I run the command DocumentSearch::FindMenuCommand
332
- Then "Regex" should be chosen in the "query_type" field in the speedbar
333
- When I run the command DocumentSearch::FindMenuCommand
334
- And I choose "Glob" in the "query_type" field in the speedbar
335
- And I close the speedbar
336
- And I run the command DocumentSearch::FindMenuCommand
337
- Then "Glob" should be chosen in the "query_type" field in the speedbar
338
-
339
- # Current Settings: Glob, Match case, Wrap around
340
-
341
- Scenario: Should reopen with the same value of Match case as the previous search
342
- When I run the command DocumentSearch::FindMenuCommand
343
- And I check "Match case" in the speedbar
344
- And I close the speedbar
345
- And I run the command DocumentSearch::FindMenuCommand
346
- Then "Match case" should be checked in the speedbar
347
- When I uncheck "Match case" in the speedbar
348
- And I close the speedbar
349
- And I run the command DocumentSearch::FindMenuCommand
350
- Then "Match case" should not be checked in the speedbar
351
-
352
- # Current Settings: Glob, No Match case, Wrap around
353
-
354
- Scenario: Should reopen with the same value of Wrap around as the previous search
355
- And I run the command DocumentSearch::FindMenuCommand
356
- And I check "Wrap around" in the speedbar
357
- And I close the speedbar
358
- And I run the command DocumentSearch::FindMenuCommand
359
- Then "Wrap around" should be checked in the speedbar
360
- When I uncheck "Wrap around" in the speedbar
361
- And I close the speedbar
362
- And I run the command DocumentSearch::FindMenuCommand
363
- Then "Wrap around" should not be checked in the speedbar
364
-
365
- # Current Settings: Glob, No Match case, Wrap around
366
-
367
334
  Scenario: Should initialize query with the currently selected text
368
335
  When I replace the contents with "Flux\nBar\nFoo"
369
336
  And I move the cursor to 0
370
337
  And I select from 0 to 4
371
- And I run the command DocumentSearch::FindMenuCommand
338
+ And I open the find speedbar
372
339
  Then the "Find" field in the speedbar should have text "Flux"
373
340
 
374
- Scenario: Search for a word should start from the start of a selection
341
+ # End: Scenarios adapted from incremental_search.feature
342
+
343
+ # Begin: Replacement scenarios specific to Find speedbar
344
+
345
+ Scenario: Replace and find with no initial selection
346
+ When I replace the contents with "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
347
+ And I move the cursor to 0
348
+ And I open the find speedbar
349
+ And I type "Rab" into the "Find" field in the speedbar
350
+ And I type "RABBIT" into the "Replace" field in the speedbar
351
+ And I press "Replace && Find" in the speedbar
352
+ Then the contents should be "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
353
+ And the selected text should be "Rab"
354
+ And the selection range should be from 12 to 15
355
+ When I press "Replace && Find" in the speedbar
356
+ Then the contents should be "Foo\nBar Foo RABBIT Rab\nHmm\nRab\nFoo\nBaz"
357
+ And the selected text should be "Rab"
358
+ And the selection range should be from 19 to 22
359
+ When I press "Replace && Find" in the speedbar
360
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRab\nFoo\nBaz"
361
+ And the selected text should be "Rab"
362
+ And the selection range should be from 30 to 33
363
+ When I press "Replace && Find" in the speedbar
364
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
365
+ And the selected text should be "RAB"
366
+ And the selection range should be from 12 to 15
367
+ When I press "Replace && Find" in the speedbar
368
+ Then the contents should be "Foo\nBar Foo RABBITBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
369
+ And the selected text should be "RAB"
370
+ And the selection range should be from 22 to 25
371
+
372
+ Scenario: Replace and find with matching initial selection
373
+ When I replace the contents with "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
374
+ And I select from 12 to 15
375
+ And I open the find speedbar
376
+ And I type "Rab" into the "Find" field in the speedbar
377
+ And I type "RABBIT" into the "Replace" field in the speedbar
378
+ And I press "Replace && Find" in the speedbar
379
+ Then the contents should be "Foo\nBar Foo RABBIT Rab\nHmm\nRab\nFoo\nBaz"
380
+ And the selected text should be "Rab"
381
+ And the selection range should be from 19 to 22
382
+ When I press "Replace && Find" in the speedbar
383
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRab\nFoo\nBaz"
384
+ And the selected text should be "Rab"
385
+ And the selection range should be from 30 to 33
386
+ When I press "Replace && Find" in the speedbar
387
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
388
+ And the selected text should be "RAB"
389
+ And the selection range should be from 12 to 15
390
+ When I press "Replace && Find" in the speedbar
391
+ Then the contents should be "Foo\nBar Foo RABBITBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
392
+ And the selected text should be "RAB"
393
+ And the selection range should be from 22 to 25
394
+
395
+ Scenario: Replace and find with initial selection that doesn't match
396
+ When I replace the contents with "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
397
+ And I select from 4 to 7
398
+ And I open the find speedbar
399
+ And I type "Rab" into the "Find" field in the speedbar
400
+ And I type "RABBIT" into the "Replace" field in the speedbar
401
+ And I press "Replace && Find" in the speedbar
402
+ Then the contents should be "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
403
+ And the selected text should be "Rab"
404
+ And the selection range should be from 12 to 15
405
+ When I press "Replace && Find" in the speedbar
406
+ Then the contents should be "Foo\nBar Foo RABBIT Rab\nHmm\nRab\nFoo\nBaz"
407
+ And the selected text should be "Rab"
408
+ And the selection range should be from 19 to 22
409
+ When I press "Replace && Find" in the speedbar
410
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRab\nFoo\nBaz"
411
+ And the selected text should be "Rab"
412
+ And the selection range should be from 30 to 33
413
+ When I press "Replace && Find" in the speedbar
414
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
415
+ And the selected text should be "RAB"
416
+ And the selection range should be from 12 to 15
417
+ When I press "Replace && Find" in the speedbar
418
+ Then the contents should be "Foo\nBar Foo RABBITBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
419
+ And the selected text should be "RAB"
420
+ And the selection range should be from 22 to 25
421
+
422
+ Scenario: Replace and find with initial selection that is after last match
423
+ When I replace the contents with "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
424
+ And I select from 28 to 31
425
+ And I open the find speedbar
426
+ And I type "Rab" into the "Find" field in the speedbar
427
+ And I type "RABBIT" into the "Replace" field in the speedbar
428
+ And I press "Replace && Find" in the speedbar
429
+ Then the contents should be "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
430
+ And the selected text should be "Rab"
431
+ And the selection range should be from 12 to 15
432
+ When I press "Replace && Find" in the speedbar
433
+ Then the contents should be "Foo\nBar Foo RABBIT Rab\nHmm\nRab\nFoo\nBaz"
434
+ And the selected text should be "Rab"
435
+ And the selection range should be from 19 to 22
436
+ When I press "Replace && Find" in the speedbar
437
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRab\nFoo\nBaz"
438
+ And the selected text should be "Rab"
439
+ And the selection range should be from 30 to 33
440
+ When I press "Replace && Find" in the speedbar
441
+ Then the contents should be "Foo\nBar Foo RABBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
442
+ And the selected text should be "RAB"
443
+ And the selection range should be from 12 to 15
444
+ When I press "Replace && Find" in the speedbar
445
+ Then the contents should be "Foo\nBar Foo RABBITBIT RABBIT\nHmm\nRABBIT\nFoo\nBaz"
446
+ And the selected text should be "RAB"
447
+ And the selection range should be from 22 to 25
448
+
449
+ Scenario: Replace and find with initial selection that is after last match and no wrap around
450
+ When I replace the contents with "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
451
+ And I select from 28 to 31
452
+ And I open the find speedbar
453
+ And I type "Rab" into the "Find" field in the speedbar
454
+ And I type "RABBIT" into the "Replace" field in the speedbar
455
+ And I uncheck "Wrap around" in the speedbar
456
+ And I press "Replace && Find" in the speedbar
457
+ Then the contents should be "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
458
+ And the selected text should be ""
459
+ And the selection range should be from 31 to 31
460
+ When I press "Replace && Find" in the speedbar
461
+ Then the contents should be "Foo\nBar Foo Rab Rab\nHmm\nRab\nFoo\nBaz"
462
+ And the selected text should be ""
463
+ And the selection range should be from 31 to 31
464
+
465
+ Scenario: Replace all replaces one
375
466
  When I replace the contents with "Foo\nBar\nBaz"
376
- And I select from 5 to 8
377
- And I run the command DocumentSearch::FindMenuCommand
378
- And I type "Ba" into the "Find" field in the speedbar
379
- Then the selected text should be "Ba"
380
- And the selection should be on line 2
467
+ And I move the cursor to 0
468
+ And I open the find speedbar
469
+ And I type "Bar" into the "Find" field in the speedbar
470
+ And I type "Rab" into the "Replace" field in the speedbar
471
+ And I uncheck "Wrap around" in the speedbar
472
+ And I press "Replace All" in the speedbar
473
+ Then the contents should be "Foo\nRab\nBaz"
474
+ And the selected text should be "Rab"
475
+ And the selection range should be from 4 to 7
381
476
 
382
- Scenario: Should match the next occurence of the currently selected text
383
- When I replace the contents with "Foo\nBar\nFoo"
477
+ Scenario: Replace all replaces two
478
+ When I replace the contents with "Foo\nBar\nBaz\nBar\nQux"
384
479
  And I move the cursor to 0
385
- And I select from 0 to 3
386
- And I run the command DocumentSearch::FindMenuCommand
387
- And I press "Next" in the speedbar
388
- Then the selected text should be "Foo"
389
- And line number 2 should be visible
480
+ And I open the find speedbar
481
+ And I type "Bar" into the "Find" field in the speedbar
482
+ And I type "Rab" into the "Replace" field in the speedbar
483
+ And I uncheck "Wrap around" in the speedbar
484
+ And I press "Replace All" in the speedbar
485
+ Then the contents should be "Foo\nRab\nBaz\nRab\nQux"
486
+ And the selected text should be "Rab"
487
+ And the selection range should be from 12 to 15
488
+
489
+ Scenario: Replace all replaces two on the same line
490
+ When I replace the contents with "abcabc"
491
+ And I open the find speedbar
492
+ And I type "bc" into the "Find" field in the speedbar
493
+ And I type "xx" into the "Replace" field in the speedbar
494
+ And I uncheck "Wrap around" in the speedbar
495
+ And I press "Replace All" in the speedbar
496
+ Then the contents should be "axxaxx"
497
+ And the selected text should be "xx"
498
+ And the selection range should be from 4 to 6
499
+ When I press "Replace All" in the speedbar
500
+ Then the contents should be "axxaxx"
501
+ And the selected text should be "xx"
502
+ And the selection range should be from 4 to 6
503
+
504
+ Scenario: Replace all replaces overlapping occurences on the same line
505
+ When I replace the contents with "deedeedeed"
506
+ And I open the find speedbar
507
+ And I type "deed" into the "Find" field in the speedbar
508
+ And I type "misdeed" into the "Replace" field in the speedbar
509
+ And I uncheck "Wrap around" in the speedbar
510
+ And I press "Replace All" in the speedbar
511
+ Then the contents should be "misdeedeemisdeed"
512
+ And the selected text should be "misdeed"
513
+ And the selection range should be from 9 to 16
514
+
515
+ Scenario: Replace all is a single undo action
516
+ When I replace the contents with "Foo\n\nabcabc\n\nBar"
517
+ And I open the find speedbar
518
+ And I type "bc" into the "Find" field in the speedbar
519
+ And I type "xx" into the "Replace" field in the speedbar
520
+ And I uncheck "Wrap around" in the speedbar
521
+ And I press "Replace All" in the speedbar
522
+ Then the contents should be "Foo\n\naxxaxx\n\nBar"
523
+ And the selected text should be "xx"
524
+ And the selection range should be from 9 to 11
525
+ When I undo
526
+ Then the contents should be "Foo\n\nabcabc\n\nBar"
527
+
528
+ Scenario: Replace all regex with back-references
529
+ When I replace the contents with "One fish\ntwo fish\nred fish\nblue fish"
530
+ And I move the cursor to 0
531
+ And I open the find speedbar
532
+ And I type "(\w+) fish" into the "Find" field in the speedbar
533
+ And I type "\1 car" into the "Replace" field in the speedbar
534
+ And I check "Regex" in the speedbar
535
+ And I uncheck "Wrap around" in the speedbar
536
+ And I press "Replace All" in the speedbar
537
+ Then the contents should be "One car\ntwo car\nred car\nblue car"
538
+ And the selected text should be "blue car"
539
+ And the selection range should be from 24 to 32
540
+
541
+ # End: Replacement scenarios specific to Find speedbar