aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--background_scripts/main.coffee41
-rw-r--r--content_scripts/vimium_frontend.coffee3
2 files changed, 22 insertions, 22 deletions
diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee
index f3df2943..816e4e45 100644
--- a/background_scripts/main.coffee
+++ b/background_scripts/main.coffee
@@ -91,33 +91,35 @@ root.isEnabledForUrl = isEnabledForUrl = (request) ->
# Enabled (the default).
{ isEnabledForUrl: true, passKeys: undefined, matchingUrl: undefined }
-# Called by the popup UI. Strips leading/trailing whitespace and ignores empty strings.
-# Also eliminates duplicates based on same URL/regexp. Of duplicates, the last is kept.
-# Excluded URL specifications are kept in the same order as they were originally, with the new exclusion at
-# the end. Passkeys, if any, are simply compied through within spec.
+# Called by the popup UI. Strips leading/trailing whitespace and ignores new empty strings.
root.addExcludedUrl = (url) ->
return unless url = url.trim()
+ parse = url.split(/\s+/)
+ url = parse[0]
+ passKeys = parse[1..].join(" ")
+ newSpec = (if passKeys then url + " " + passKeys else url)
+
excludedUrls = Settings.get("excludedUrls").split("\n")
- excludedUrls.push(url)
+ excludedUrls.push(newSpec)
- # Eliminate duplicates: reverse list, filter out duplicates based only on the URL/regexp, then reverse again
- # and install the new excludedUrls. parse[0] is the URL/regexp.
- seen = {}
+ # Update excludedUrls.
+ # Try to keep the list as unchanged as possible: same order, same comments, same blank lines.
+ seenNew = false
newExcludedUrls = []
- for spec in excludedUrls.reverse()
+ for spec in excludedUrls
spec = spec.trim()
parse = spec.split(/\s+/)
- if parse.length == 0 or spec.indexOf("#") == 0
- # Keep comments and empty lines.
- newExcludedUrls.push(spec)
- else if !seen[parse[0]]
- seen[parse[0]] = true
- newExcludedUrls.push(spec)
- else
- console.log "addExcludedUrl: removing " + spec
+ # Keep just one copy of the new exclusion rule.
+ if parse.length and parse[0] == url
+ if !seenNew
+ newExcludedUrls.push(newSpec)
+ seenNew = true
+ continue
+ # And just keep everything else.
+ newExcludedUrls.push(spec)
- Settings.set("excludedUrls", newExcludedUrls.reverse().join("\n"))
+ Settings.set("excludedUrls", newExcludedUrls.join("\n"))
chrome.tabs.query({ windowId: chrome.windows.WINDOW_ID_CURRENT, active: true },
(tabs) -> updateActiveState(tabs[0].id))
@@ -528,8 +530,7 @@ handleKeyDown = (request, port) ->
console.log("checking keyQueue: [", keyQueue + key, "]")
keyQueue = checkKeyQueue(keyQueue + key, port.sender.tab.id, request.frameId)
console.log("new KeyQueue: " + keyQueue)
- # Tell the content script whether there are keys in the queue. If there are, then subsequent keys in passKeys will be
- # handled by vimium. So, if 't' is a passKey, then 'gt' and '99t' will nevertheless be handled by Vimium.
+ # Tell the content script whether there are keys in the queue.
# FIXME: There is a race condition here. The behaviour in the content script depends upon whether this message gets
# back there before or after the next keystroke.
# That being said, I suspect there are other similar race conditions here, for example in checkKeyQueue().
diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee
index feebda07..34473e96 100644
--- a/content_scripts/vimium_frontend.coffee
+++ b/content_scripts/vimium_frontend.coffee
@@ -117,10 +117,9 @@ initializePreDomReady = ->
getScrollPosition: -> scrollX: window.scrollX, scrollY: window.scrollY
setScrollPosition: (request) -> setScrollPosition request.scrollX, request.scrollY
executePageCommand: executePageCommand
- # FIXME: currentKeyQueue(), below, does not respect the frameId. Should it?
- currentKeyQueue: (request) -> keyQueue = request.keyQueue
getActiveState: -> { enabled: isEnabledForUrl }
disableVimium: disableVimium
+ currentKeyQueue: (request) -> keyQueue = request.keyQueue
chrome.runtime.onMessage.addListener (request, sender, sendResponse) ->
# in the options page, we will receive requests from both content and background scripts. ignore those