diff --git a/lib/ace/incremental_search.js b/lib/ace/incremental_search.js index 5d439c81..806622a3 100644 --- a/lib/ace/incremental_search.js +++ b/lib/ace/incremental_search.js @@ -168,6 +168,32 @@ oop.inherits(IncrementalSearch, Search); exports.IncrementalSearch = IncrementalSearch; +/** + * + * Config settings for enabling/disabling [[IncrementalSearch `IncrementalSearch`]]. + * + **/ + +function patchHighlightMarkerStyling(options) { + options = options || {}; + var id = 'incremental-search-highlight-style-patch', + style = document.getElementById(id); + if (style) { + if (options.enable) return; + style.parentNode.removeChild(style); + return; + } + if (!options.enable) return; + style = document.createElement('style'); + style.setAttribute('id', id); + style.textContent = "div.ace_selected-word {\n" + + " background-color: orange !important;\n" + + " border: 0 !important;" + + "}\n" + document.getElementsByTagName('head')[0].appendChild(style); +} + + var Editor = require("./editor").Editor; require("./config").defineOptions(Editor.prototype, "editor", { useIncrementalSearch: { @@ -177,6 +203,7 @@ require("./config").defineOptions(Editor.prototype, "editor", { if (val) { // enable for whole editor this.commands.addCommands(iSearchCommands); + patchHighlightMarkerStyling({enable: true}); if (kbd.isEmacs) { // adapt emacs key handler if used kbd.oldSearchBindings = { 'c-s': kbd.commmandKeyBinding['c-s'], @@ -187,6 +214,7 @@ require("./config").defineOptions(Editor.prototype, "editor", { } } else { this.commands.removeCommands(iSearchCommands); + patchHighlightMarkerStyling({enable: false}); if (kbd.isEmacs) { kbd.bindKey('C-s', kbd.oldSearchBindings['c-s']); kbd.bindKey('C-r', kbd.oldSearchBindings['c-r']);