Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add ctrl-u to clear query #34

Merged
merged 1 commit into from

2 participants

@dlee

Fixes #33

@garybernhardt garybernhardt merged commit 8a2d1f3 into from
@garybernhardt

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 26, 2014
  1. @dlee

    Add ctrl-u to clear query

    dlee authored
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 0 deletions.
  1. +7 −0 selecta
  2. +9 −0 spec/search_spec.rb
View
7 selecta
@@ -23,6 +23,7 @@ require "io/console"
KEY_CTRL_C = ?\C-c
KEY_CTRL_N = ?\C-n
KEY_CTRL_P = ?\C-p
+KEY_CTRL_U = ?\C-u
KEY_CTRL_W = ?\C-w
KEY_DELETE = 127.chr # Equivalent to ?\C-?
@@ -73,6 +74,7 @@ class Selecta
when KEY_CTRL_N then search.down
when KEY_CTRL_P then search.up
+ when KEY_CTRL_U then search.clear_query
when KEY_CTRL_W then search.delete_word
when KEY_DELETE then search.backspace
@@ -202,6 +204,11 @@ class Search
:query => @query[0...-1])
end
+ def clear_query
+ merge(:index => 0,
+ :query => "")
+ end
+
def delete_word
merge(:index => 0,
:query => @query.sub(/[^ ]* *$/, ""))
View
9 spec/search_spec.rb
@@ -55,6 +55,15 @@
search.append_search_string(" a b").delete_word.query.should == " a "
end
+ it "clears query" do
+ search.append_search_string("").clear_query.query.should == ""
+ search.append_search_string("a").clear_query.query.should == ""
+ search.append_search_string("a ").clear_query.query.should == ""
+ search.append_search_string("a b").clear_query.query.should == ""
+ search.append_search_string("a b ").clear_query.query.should == ""
+ search.append_search_string(" a b").clear_query.query.should == ""
+ end
+
describe "matching" do
it "only returns matching choices" do
config = Configuration.from_inputs(["a", "b"],
Something went wrong with that request. Please try again.