diff --git a/content/hints.js b/content/hints.js index 2851f7c0..b1c974ef 100644 --- a/content/hints.js +++ b/content/hints.js @@ -403,22 +403,76 @@ liberator.Hints = function () //{{{ function charsAtBeginningOfWords(chars, words, allowWordOverleaping) { - var charIdx = 0; + var charIdx = 0; + var numMatchedWords = 0; for (var wIdx = 0; wIdx < words.length; wIdx++) { var word = words[wIdx]; if (word.length == 0) continue; - var prevCharIdx = charIdx; - for (var j = 0; j < word.length && charIdx < chars.length; j++, charIdx++) + var wcIdx = 0; + // Check if the current word matches same characters as the previous word. + // Each already matched word has matched at least one character. + if (charIdx > numMatchedWords) { - if (word[j] != chars[charIdx]) - break; + var matchingStarted = false; + for (var i = numMatchedWords; i < charIdx; i++) + { + if (chars[i] == word[wcIdx]) + { + matchingStarted = true; + wcIdx++; + } + else if (matchingStarted) + { + wcIdx = 0; + break; + } + } } - if (prevCharIdx == charIdx && ! allowWordOverleaping) - return false; + // the current word matches same characters as the previous word + if (wcIdx > 0) { + var prevCharIdx = charIdx; + // now check if it matches additional characters + for (; wcIdx < word.length && charIdx < chars.length; wcIdx++, charIdx++) + { + if (word[wcIdx] != chars[charIdx]) + break; + } + + // the word doesn't match additional characters, now check if the + // already matched characters are equal to the next characters for matching, + // if yes, then consume them + if (prevCharIdx == charIdx) + { + for (var i = 0; i < wcIdx && charIdx < chars.length; i++, charIdx++) + { + if (word[i] != chars[charIdx]) + break; + } + } + + numMatchedWords++; + } + // the current word doesn't match same characters as the previous word, just + // try to match the next characters + else { + var prevCharIdx = charIdx; + for (var i = 0; i < word.length && charIdx < chars.length; i++, charIdx++) + { + if (word[i] != chars[charIdx]) + break; + } + + if (prevCharIdx == charIdx) { + if (! allowWordOverleaping) + return false; + } + else + numMatchedWords++; + } if (charIdx == chars.length) return true; diff --git a/locale/en-US/options.txt b/locale/en-US/options.txt index 239a9ed3..a49cf77d 100644 --- a/locale/en-US/options.txt +++ b/locale/en-US/options.txt @@ -21,7 +21,7 @@ section:Setting{nbsp}options[set-option,E764] ||:se[t] {option}?|| Show value of {option}. -||:se[t] {option}|| Toggle option: set, switch it on. +||:se[t] {option}|| Toggle option: set, switch it on. ____ Number option: show value. + String option: show value. @@ -95,6 +95,7 @@ all Firefox preferences work, because Vimperator overrides some key bindings and changes Firefox's GUI. ________________________________________________________________________________ + |:prefs!| |:preferences!| ||:pref[erences]!|| ________________________________________________________________________________ @@ -103,6 +104,14 @@ preferences. ________________________________________________________________________________ +|:set-!| +||:se[t]! {preference}={value}|| + +________________________________________________________________________________ +Change any Firefox {preference} (those in the about:config window). You can also +reset/delete those preferences with [c]:set! {preference}&[c]. +________________________________________________________________________________ + + section:List{nbsp}of{nbsp}options[list-options] |\'act'| |\'activate'| @@ -228,7 +237,6 @@ ____ A regex which defines the word separators which are used for the 'hintmatching' types 'wordstartswith' and 'firstletters' to split the words in the text of a link. + -NOTE: Because 'wordseparators' is a string, each backspace has to be quoted by another backspace. ____