Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions content_scripts/hud.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const HUD = {
tween: null,
hudUI: null,
findMode: null,
searchTimeout: null,
abandon() {
if (this.hudUI) {
this.hudUI.hide(false);
Expand Down Expand Up @@ -86,16 +87,22 @@ const HUD = {
},

search(data) {
// NOTE(mrmr1993): On Firefox, window.find moves the window focus away from the HUD. We use
// postFindFocus to put it back, so the user can continue typing.
this.findMode.findInPlace(data.query, {
"postFindFocus": this.hudUI.iframeElement.contentWindow,
});
if (this.searchTimeout) {
clearTimeout(this.searchTimeout);
}

// Show the number of matches in the HUD UI.
const matchCount = FindMode.query.parsedQuery.length > 0 ? FindMode.query.matchCount : 0;
const showMatchText = FindMode.query.rawQuery.length > 0;
this.hudUI.postMessage({ name: "updateMatchesCount", matchCount, showMatchText });
this.searchTimeout = Utils.setTimeout(300, () => {
// NOTE(mrmr1993): On Firefox, window.find moves the window focus away from the HUD. We use
// postFindFocus to put it back, so the user can continue typing.
this.findMode.findInPlace(data.query, {
"postFindFocus": this.hudUI.iframeElement.contentWindow,
});

// Show the number of matches in the HUD UI.
const matchCount = FindMode.query.parsedQuery.length > 0 ? FindMode.query.matchCount : 0;
const showMatchText = FindMode.query.rawQuery.length > 0;
this.hudUI.postMessage({ name: "updateMatchesCount", matchCount, showMatchText });
});
},

// Hide the HUD.
Expand Down