Permalink
Browse files

Fix the Goto line command.

  • Loading branch information...
1 parent b7d37e6 commit a853c343312194be75db279d304f87a5e6530d15 @danlucraft committed Oct 24, 2010
Showing with 29 additions and 9 deletions.
  1. +1 −0 CHANGES
  2. +20 −0 plugins/redcar/features/goto_line_command.feature
  3. +8 −9 plugins/redcar/redcar.rb
View
@@ -23,6 +23,7 @@ Bugfixes:
* Can load files with multi-byte characters and see them in the tree (Dan Lucraft)
* Open in command line now works correctly with Terminal.app (Delisa Mason, Mat Schaffer)
* Search-and-replace won't loop forever over a document anymore if it still finds the search string (Tim Felgentreff)
+ * Goto line command works again (Dan Lucraft)
New APIs:
* after_save can be implemented by plugins to run code after an edit view was saved (Tim Felgentreff)
@@ -0,0 +1,20 @@
+
+@speedbar
+Feature: Goto line command
+
+ Background:
+ Given I open a new edit tab
+
+ Scenario: Open goto line speedbar
+ When I replace the contents with "Foo\nBar\nBaz"
+ And I move the cursor to 0
+ And I run the command Redcar::Top::GotoLineCommand
+ Then the Redcar::Top::GotoLineCommand::Speedbar speedbar should be open
+
+ Scenario: Search for a word should select next occurrence
+ When I replace the contents with "Foo\nBar\nBaz"
+ And I move the cursor to 0
+ And I run the command Redcar::Top::GotoLineCommand
+ And I type "2" into the "line" field in the speedbar
+ And I press "Go" in the speedbar
+ Then the cursor should be on line 1
View
@@ -660,23 +660,22 @@ class Speedbar < Redcar::Speedbar
button :go, "Go", "Return" do
new_line_ix = line.value.to_i - 1
- if new_line_ix < doc.line_count and new_line_ix >= 0
- doc.cursor_offset = doc.offset_at_line(new_line_ix)
- doc.scroll_to_line(new_line_ix)
- win.close_speedbar
+ if new_line_ix < @doc.line_count and new_line_ix >= 0
+ @doc.cursor_offset = @doc.offset_at_line(new_line_ix)
+ @doc.scroll_to_line(new_line_ix)
+ @win.close_speedbar
end
end
- def initialize(command)
+ def initialize(command, win)
@command = command
+ @doc = command.doc
+ @win = win
end
-
- def doc; @command.doc; end
- def win; @command.send(:win); end
end
def execute
- @speedbar = GotoLineCommand::Speedbar.new(self)
+ @speedbar = GotoLineCommand::Speedbar.new(self, win)
win.open_speedbar(@speedbar)
end
end

0 comments on commit a853c34

Please sign in to comment.