diff options
| author | Stephen Blott | 2016-02-14 07:56:35 +0000 |
|---|---|---|
| committer | Stephen Blott | 2016-02-14 07:56:35 +0000 |
| commit | 54b8957942545b89989a5c8b71238d60be6349e5 (patch) | |
| tree | bb3420e52383339778af50a8b0710058d5f808b3 /content_scripts | |
| parent | 58f9bf87102ce0851bd9ad636b27e190f4a4b496 (diff) | |
| parent | f05712bd4128bbd5d01d0487e026ba9dd11c8bd4 (diff) | |
| download | vimium-54b8957942545b89989a5c8b71238d60be6349e5.tar.bz2 | |
Merge pull request #1993 from smblott-github/filtered-hints-word-split
Split filtered hints on non-word and hint characters.
Diffstat (limited to 'content_scripts')
| -rw-r--r-- | content_scripts/link_hints.coffee | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index 6f95ac57..db8fe300 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -479,6 +479,9 @@ class FilterHints @linkTextKeystrokeQueue = [] @labelMap = {} @activeHintMarker = null + # The regexp for splitting typed text and link texts. We split on sequences of non-word characters and + # link-hint numbers. + @splitRegexp = new RegExp "[\\W#{Utils.escapeRegexSpecialCharacters @linkHintNumbers}]+" # # Generate a map of input element => label @@ -602,10 +605,10 @@ class FilterHints # Assign a score to a filter match (higher is better). We assign a higher score for matches at the start of # a word, and a considerably higher score still for matches which are whole words. scoreLinkHint: (linkSearchString) -> - searchWords = linkSearchString.trim().split /\s+/ - (linkMarker) -> + searchWords = linkSearchString.trim().split @splitRegexp + (linkMarker) => text = linkMarker.linkText.trim() - linkWords = linkMarker.linkWords ?= text.toLowerCase().split /\s+/ + linkWords = linkMarker.linkWords ?= text.toLowerCase().split @splitRegexp searchWordScores = for searchWord in searchWords |
