[incremental search] quit isearch on mousedown

This commit is contained in:
Robert Krahn 2013-03-16 22:36:19 -07:00
commit 569563aa5f

View file

@ -71,6 +71,7 @@ oop.inherits(IncrementalSearch, Search);
this.$options.needle = '';
this.$options.backwards = backwards;
editor.keyBinding.addKeyboardHandler(this.$keyboardHandler);
this.$mousedownHandler = editor.addEventListener('mousedown', this.onMouseDown.bind(this));
this.selectionFix(editor);
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
var msg = this.$options.backwards ? 'reverse-' : '';
@ -81,6 +82,10 @@ oop.inherits(IncrementalSearch, Search);
this.deactivate = function(reset) {
this.cancelSearch(reset);
this.$editor.keyBinding.removeKeyboardHandler(this.$keyboardHandler);
if (this.$mousedownHandler) {
this.$editor.removeEventListener('mousedown', this.$mousedownHandler);
delete this.$mousedownHandler;
}
this.message('');
}
@ -94,6 +99,7 @@ oop.inherits(IncrementalSearch, Search);
editor.clearSelection();
}
}
this.cancelSearch = function(reset) {
var e = this.$editor;
this.$prevNeedle = this.$options.needle;
@ -164,6 +170,12 @@ oop.inherits(IncrementalSearch, Search);
});
}
this.onMouseDown = function(evt) {
// when mouse interaction happens then we quit incremental search
this.deactivate();
return true;
}
this.message = function(msg) {
var cmdLine = this.$editor && this.$editor.cmdLine;
if (cmdLine) {
@ -173,7 +185,6 @@ oop.inherits(IncrementalSearch, Search);
}
}
}).call(IncrementalSearch.prototype);