From a8842428a5a0bddf7b7dcb3d3d5aaaeb4c70a374 Mon Sep 17 00:00:00 2001 From: Jez Ng Date: Sun, 29 Jan 2012 09:06:54 -0500 Subject: 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). --- vimiumFrontend.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) (limited to 'vimiumFrontend.js') 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 s are necessary because the zero-width space tends to interfere - // with subsequent characters in the same text node. - return query.split("").join(""); + 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; }, -- cgit v1.2.3