Skip to content

Commit 29be781

Browse files
committed
don't show findbar on no matches through the command line
1 parent 375dd7f commit 29be781

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

common/content/finder.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,15 +128,27 @@ var Finder = Module("finder", {
128128

129129
// PDF.JS files are different, they use their own messages to communicate the results.
130130
// So we piggyback the end changes to the findbar when there are any.
131-
findbar._original_updateControlState = findbar.updateControlState;
131+
findbar._vimpbackup_updateControlState = findbar.updateControlState;
132132
findbar.updateControlState = function(aResult, aFindPrevious) {
133-
this._original_updateControlState(aResult, aFindPrevious);
133+
this._vimpbackup_updateControlState(aResult, aFindPrevious);
134134
finder.onFindResult({
135135
searchString: this._findField.value,
136136
result: aResult,
137137
findBackwards: aFindPrevious
138138
});
139139
};
140+
141+
// Normally the findbar appears to notify on failed results.
142+
// However, this shouldn't happen when we're finding through the command line,
143+
// even though that way we lose any kind of no matches notification until we
144+
// stop typing altogether; something to work on at a later time:
145+
// - show the quick findbar which will hide after a few seconds?
146+
// - or notify the user somehow in the command line itself?
147+
findbar._vimpbackup_open = findbar.open;
148+
findbar.open = function (aMode) {
149+
if (commandline._keepOpenForInput) { return false; }
150+
return this._vimpbackup_open(aMode);
151+
};
140152
}
141153

142154
findbar._find();
@@ -278,6 +290,18 @@ var Finder = Module("finder", {
278290
function () { finder.clear(); },
279291
{ argCount: "0" });
280292
},
293+
events: function() {
294+
if (config.name == 'Vimperator') {
295+
// Same thing as the note above for not showing the findbar on failed results
296+
// through the command line, but for compatibility with FindBar Tweak.
297+
events.addSessionListener(window, "WillOpenFindBar", function (event) {
298+
if (commandline._keepOpenForInput) {
299+
event.preventDefault();
300+
event.stopPropagation();
301+
}
302+
}, true);
303+
}
304+
},
281305
mappings: function () {
282306
var myModes = config.browserModes;
283307
myModes = myModes.concat([modes.CARET]);

0 commit comments

Comments
 (0)