diff --git a/CHANGES b/CHANGES index d22d89e79..05c3753a2 100644 --- a/CHANGES +++ b/CHANGES @@ -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: diff --git a/plugins/edit_tab/commands/select_word_command.rb b/plugins/edit_tab/commands/select_word_command.rb new file mode 100644 index 000000000..58d46f8ea --- /dev/null +++ b/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 diff --git a/plugins/edit_tab/features/editing.feature b/plugins/edit_tab/features/editing.feature index 814309bff..5ec9669cb 100644 --- a/plugins/edit_tab/features/editing.feature +++ b/plugins/edit_tab/features/editing.feature @@ -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 bar" 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 bar" 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 " in the EditTab + + + + diff --git a/plugins/redcar/redcar.rb b/plugins/redcar/redcar.rb index a161abcb9..c1620dfee 100644 --- a/plugins/redcar/redcar.rb +++ b/plugins/redcar/redcar.rb @@ -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