Skip to content

Commit

Permalink
Added SelectWordCommand from itrekkie
Browse files Browse the repository at this point in the history
  • Loading branch information
danlucraft committed Jun 27, 2009
1 parent 98fc680 commit ca34440
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CHANGES
Expand Up @@ -5,11 +5,13 @@ Version 0.3 (TBA)
New features, enhancements:

* Autocompletion (hit Escape)
* Select Word command

New contributors:

* aokai
* Silvio Heuberger (kung_foo)
* itrekkie

Planned:

Expand Down
19 changes: 19 additions & 0 deletions plugins/edit_tab/commands/select_word_command.rb
@@ -0,0 +1,19 @@
module Redcar
class SelectWordCommand < Redcar::EditTabCommand
key "Super+W"

def execute
start = doc.cursor_iter
finish = doc.cursor_iter

unless start.inside_word? or start.starts_word? or start.ends_word?
return
end

start.backward_word_start unless start.starts_word?
finish.forward_word_end unless finish.ends_word?

doc.select(start, finish)
end
end
end
19 changes: 19 additions & 0 deletions plugins/edit_tab/features/editing.feature
Expand Up @@ -121,3 +121,22 @@ Feature: Edit Text
And I press "Return" then "Ctrl+Alt+B"
And I press "Ctrl+Super+V" then "Ctrl+Super+V"
Then I should see "b" in the EditTab

Scenario: Select word
When I type "foo bar"
And I press "Left" then "Super+W"
Then I should see "foo <s>bar<c>" in the EditTab

Scenario: Select word at end of word
When I type "foo bar"
And I press "Super+W"
Then I should see "foo <s>bar<c>" in the EditTab

Scenario: Select word does nothing outside of word
When I type "foo bar "
And I press "Super+W"
Then I should see "foo bar <c>" in the EditTab




5 changes: 3 additions & 2 deletions plugins/redcar/redcar.rb
Expand Up @@ -58,8 +58,9 @@ def self.load(plugin)
end
separator
submenu "Select" do
item "Line", SelectLine
item "Current Scope", SelectScopeCommand
item "Word", SelectWordCommand
item "Line", SelectLine
item "Current Scope", SelectScopeCommand
end
end

Expand Down

0 comments on commit ca34440

Please sign in to comment.