Skip to content

Commit

Permalink
Fix the Goto line command.
Browse files Browse the repository at this point in the history
  • Loading branch information
danlucraft committed Oct 24, 2010
1 parent b7d37e6 commit a853c34
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -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)
Expand Down
20 changes: 20 additions & 0 deletions plugins/redcar/features/goto_line_command.feature
@@ -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
17 changes: 8 additions & 9 deletions plugins/redcar/redcar.rb
Expand Up @@ -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
Expand Down

0 comments on commit a853c34

Please sign in to comment.