aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2015-05-10 22:01:39 +0100
committerStephen Blott2015-05-10 22:01:39 +0100
commit6d0e3a0f019e85fd76a92cb015ffcfb0d44a4e07 (patch)
treeb4c0bd447a9932ecc1869c9187dd5a98d9dec815
parent447115fdc5eccf0edebd3c24eec9dd7f94a2eae2 (diff)
downloadvimium-6d0e3a0f019e85fd76a92cb015ffcfb0d44a4e07.tar.bz2
Search completion; alternative vomnibar completion.
-rw-r--r--background_scripts/completion.coffee2
-rw-r--r--pages/vomnibar.coffee22
2 files changed, 11 insertions, 13 deletions
diff --git a/background_scripts/completion.coffee b/background_scripts/completion.coffee
index e09d01ef..018740c0 100644
--- a/background_scripts/completion.coffee
+++ b/background_scripts/completion.coffee
@@ -466,7 +466,7 @@ class SearchEngineCompleter
insertText: suggestion
highlightTerms: false
selectCommonMatches: true
- custonSearchEngineCompletionSuggestion: true
+ customSearchEngineCompletionSuggestion: true
# If we have cached suggestions, then we can bundle them immediately (otherwise we'll have to fetch them
# asynchronously).
diff --git a/pages/vomnibar.coffee b/pages/vomnibar.coffee
index a52b14b3..5cd2e2f1 100644
--- a/pages/vomnibar.coffee
+++ b/pages/vomnibar.coffee
@@ -201,13 +201,12 @@ class VomnibarUI
# We only highlight matches when the query gets longer (so, not on deletions).
return unless previousLength < currentLength
- completion = do =>
+ completion = do (completion) =>
for completion in @completions
continue if completion.custonSearchEnginePrimarySuggestion
- return completion if completion.custonSearchEngineCompletionSuggestion
- return null
+ return completion if completion.customSearchEngineCompletionSuggestion
+ null
- console.log 1
return unless completion
# Fetch the query and suggestion.
@@ -215,13 +214,10 @@ class VomnibarUI
suggestion = completion.title
index = suggestion.toLowerCase().indexOf query
- console.log 2
- return unless index <= 1
+ return unless 0 <= index
suggestion = suggestion[index..]
- console.log 3, suggestion
return unless query.length < suggestion.length
- console.log 4
# If the typed text is all lower case, then make the completion lower case too.
suggestion = suggestion.toLowerCase() unless /[A-Z]/.test @getInputWithoutSelectionRange()
@@ -263,11 +259,13 @@ class VomnibarUI
else if action in [ "tab", "down" ]
if action == "tab"
if @inputContainsASelectionRange()
- # The first tab collapses the selection to the end.
- window.getSelection()?.collapseToEnd()
- @updateOnInput()
+ # Tab moves the start of the selection to the end of the current word.
+ text = @input.value[@input.selectionStart..]
+ length = text.length
+ text = text.replace /^\s*\S+/, ""
+ @input.setSelectionRange @input.selectionStart + (length - text.length), @input.selectionEnd
else
- # Subsequent tabs behave the same as "down".
+ # Other tabs behave the same as "down".
action = "down"
if action == "down"
@selection += 1