Skip to content

Commit 6de6aa3

Browse files
committed
Merge pull request #412 from Quicksaver/findbar-fixes
Findbar fixes
2 parents 0f47a14 + 43069f0 commit 6de6aa3

File tree

2 files changed

+41
-4
lines changed

2 files changed

+41
-4
lines changed

common/content/commandline.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -421,6 +421,16 @@ const CommandLine = Module("commandline", {
421421
}
422422
},
423423

424+
_isIMEComposing: false,
425+
426+
onCompositionStart: function(e) {
427+
this._isIMEComposing = true;
428+
},
429+
430+
onCompositionEnd: function(e) {
431+
this._isIMEComposing = false;
432+
},
433+
424434
get command() {
425435
try {
426436
// The long path is because of complications with the
@@ -1529,6 +1539,12 @@ const CommandLine = Module("commandline", {
15291539
literal: 0
15301540
});
15311541
},
1542+
events: function() {
1543+
// The commandline should know when the user is inputting complex text, some functionalities may depend on it; i.e. finder.js
1544+
let textbox = document.getElementById("liberator-commandline-command");
1545+
events.addSessionListener(textbox, "compositionstart", this.closure.onCompositionStart);
1546+
events.addSessionListener(textbox, "compositionend", this.closure.onCompositionEnd);
1547+
},
15321548
mappings: function () {
15331549
var myModes = [modes.COMMAND_LINE];
15341550

common/content/finder.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ var Finder = Module("finder", {
100100
this._backwards = mode == modes.SEARCH_BACKWARD;
101101
//commandline.open(this._backwards ? "Find backwards" : "Find", "", mode);
102102
commandline.input(this._backwards ? "Find backwards" : "Find", this.closure.onSubmit, {
103-
onChange: function() { if (options["incsearch"]) finder.find(commandline.command) }
103+
onChange: function() {
104+
if (options["incsearch"] && !commandline._isIMEComposing) {
105+
finder.find(commandline.command);
106+
}
107+
}
104108
});
105109
//modes.extended = mode;
106110

@@ -124,15 +128,27 @@ var Finder = Module("finder", {
124128

125129
// PDF.JS files are different, they use their own messages to communicate the results.
126130
// So we piggyback the end changes to the findbar when there are any.
127-
findbar._original_updateControlState = findbar.updateControlState;
131+
findbar._vimpbackup_updateControlState = findbar.updateControlState;
128132
findbar.updateControlState = function(aResult, aFindPrevious) {
129-
this._original_updateControlState(aResult, aFindPrevious);
133+
this._vimpbackup_updateControlState(aResult, aFindPrevious);
130134
finder.onFindResult({
131135
searchString: this._findField.value,
132136
result: aResult,
133137
findBackwards: aFindPrevious
134138
});
135139
};
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+
};
136152
}
137153

138154
findbar._find();
@@ -160,7 +176,12 @@ var Finder = Module("finder", {
160176
*/
161177
onFindResult: function(aData) {
162178
if (aData.result == Ci.nsITypeAheadFind.FIND_NOTFOUND) {
163-
liberator.echoerr("Pattern not found: " + aData.searchString, commandline.FORCE_SINGLELINE);
179+
// Don't use aData.searchString, it may be a substring of the
180+
// user's actual input text and that can be confusing.
181+
// See https://github.com/vimperator/vimperator-labs/issues/401#issuecomment-180522987
182+
// for an example.
183+
let searchString = this.findbar._findField.value;
184+
liberator.echoerr("Pattern not found: " + searchString, commandline.FORCE_SINGLELINE);
164185
}
165186
else if (aData.result == Ci.nsITypeAheadFind.FIND_WRAPPED) {
166187
let msg = aData.findBackwards ? "Search hit TOP, continuing at BOTTOM" : "Search hit BOTTOM, continuing at TOP";

0 commit comments

Comments
 (0)