diff --git a/lib/ace/ext/searchbox.js b/lib/ace/ext/searchbox.js index a0d8d6da..3eacb580 100644 --- a/lib/ace/ext/searchbox.js +++ b/lib/ace/ext/searchbox.js @@ -122,9 +122,11 @@ var SearchBox = function(editor, range, showReplaceForm) { }); event.addListener(this.searchInput, "focus", function() { _this.activeInput = _this.searchInput; + _this.searchInput.value && _this.highlight(); }); event.addListener(this.replaceInput, "focus", function() { _this.activeInput = _this.replaceInput; + _this.searchInput.value && _this.highlight(); }); }; @@ -199,6 +201,10 @@ var SearchBox = function(editor, range, showReplaceForm) { this.find(false, false); }; + this.highlight = function(re) { + this.editor.session.highlight(re || this.editor.$search.$options.re); + this.editor.renderer.updateBackMarkers() + }; this.find = function(skipCurrent, backwards) { var range = this.editor.find(this.searchInput.value, { skipCurrent: skipCurrent, @@ -209,7 +215,7 @@ var SearchBox = function(editor, range, showReplaceForm) { wholeWord: this.wholeWordOption.checked }); dom.setCssClass(this.searchBox, "ace_nomatch", !range && this.searchInput.value); - this.editor.session.highlight(this.editor.$search.$options.re); + this.highlight(); }; this.findNext = function() { this.find(true, false);