diff options
| author | Jez Ng | 2012-01-29 09:06:54 -0500 |
|---|---|---|
| committer | Jez Ng | 2012-01-29 23:48:15 -0500 |
| commit | a8842428a5a0bddf7b7dcb3d3d5aaaeb4c70a374 (patch) | |
| tree | 1da85b806a8c97e8576d58646b02818f2b4a55b4 /vimiumFrontend.js | |
| parent | 6fa1109ef7b2834d027b296744aa4399ce5408b8 (diff) | |
| download | vimium-a8842428a5a0bddf7b7dcb3d3d5aaaeb4c70a374.tar.bz2 | |
Really prevent find mode from matching its own searches.
We do this by hiding the HUD before each search -- this should be 100%
foolproof.
Zero-width spaces did not do the job at all, while spaces of font size 0
were not always invisible (see e1e178b).
Diffstat (limited to 'vimiumFrontend.js')
| -rw-r--r-- | vimiumFrontend.js | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/vimiumFrontend.js b/vimiumFrontend.js index 5cf3a4cc..70bcc718 100644 --- a/vimiumFrontend.js +++ b/vimiumFrontend.js @@ -752,6 +752,8 @@ function executeFind(query, options) { document.body.classList.add("vimiumFindMode"); + // prevent find from matching its own search query in the HUD + HUD.hide(true); // ignore the selectionchange event generated by find() document.removeEventListener("selectionchange",restoreDefaultSelectionHighlight, true); var rv = window.find(query, options.caseSensitive, options.backwards, true, false, true, false); @@ -826,7 +828,7 @@ function findAndFocus(backwards) { findModeQueryHasResults = executeFind(query, { backwards: backwards, caseSensitive: !findModeQuery.ignoreCase }); if (!findModeQueryHasResults) { - HUD.showForDuration(insertSpaces("No matches for '" + findModeQuery.rawQuery + "'"), 1000); + HUD.showForDuration("No matches for '" + findModeQuery.rawQuery + "'", 1000); return; } @@ -964,18 +966,9 @@ function goNext() { function showFindModeHUDForQuery() { if (findModeQueryHasResults || findModeQuery.parsedQuery.length == 0) - HUD.show("/" + insertSpaces(findModeQuery.rawQuery)); + HUD.show("/" + findModeQuery.rawQuery); else - HUD.show("/" + insertSpaces(findModeQuery.rawQuery + " (No Matches)")); -} - -/* - * We need this so that the find mode HUD doesn't match its own searches. - */ -function insertSpaces(query) { - // ​ is a zero-width space. the <span>s are necessary because the zero-width space tends to interfere - // with subsequent characters in the same text node. - return query.split("").join("<span class='vimiumReset'>​</span>"); + HUD.show("/" + findModeQuery.rawQuery + " (No Matches)"); } function enterFindMode() { @@ -1107,10 +1100,13 @@ HUD = { return element; }, - hide: function() { + hide: function(immediate) { clearInterval(HUD._tweenId); - HUD._tweenId = Tween.fade(HUD.displayElement(), 0, 150, - function() { HUD.displayElement().style.display = "none"; }); + if (immediate) + HUD.displayElement().style.display = "none"; + else + HUD._tweenId = Tween.fade(HUD.displayElement(), 0, 150, + function() { HUD.displayElement().style.display = "none"; }); this.isShowing = false; }, |
