diff --git a/lib/ace/incremental_search.js b/lib/ace/incremental_search.js index 4fefcb0d..969ac9ba 100644 --- a/lib/ace/incremental_search.js +++ b/lib/ace/incremental_search.js @@ -208,34 +208,17 @@ function patchHighlightMarkerStyling(options) { dom.importCssString(css, id); } - // support for default keyboard handler -require(["./commands/command_manager"], function(cmdMgr) { - (function() { - this.setupIncrementalSearch = function(editor, val) { - if (this.usesIncrementalSearch == val) return; - this.usesIncrementalSearch = val; - var iSearchCommands = iSearchCommandModule.iSearchStartCommands, - method = val ? 'addCommands' : 'removeCommands'; - this[method](iSearchCommands); - }; - }).call(cmdMgr.CommandManager.prototype); -}); - -// support for emacskeyboard handler -require(["./keyboard/emacs"], function(emacs) { - emacs.handler.setupIncrementalSearch = function(editor, val) { +var commands = require("./commands/command_manager"); +(function() { + this.setupIncrementalSearch = function(editor, val) { if (this.usesIncrementalSearch == val) return; this.usesIncrementalSearch = val; - if (val) { - this.bindKey('C-s', 'iSearch'); - this.bindKey('C-r', 'iSearchBackwards'); - } else { - this.bindKey('C-s', "findnext"); - this.bindKey('C-r', "findprevious"); - } - } -}); + var iSearchCommands = iSearchCommandModule.iSearchStartCommands, + method = val ? 'addCommands' : 'removeCommands'; + this[method](iSearchCommands); + }; +}).call(commands.CommandManager.prototype); // incremental search config option var Editor = require("./editor").Editor; diff --git a/lib/ace/keyboard/emacs.js b/lib/ace/keyboard/emacs.js index 218d730d..ff397fa2 100644 --- a/lib/ace/keyboard/emacs.js +++ b/lib/ace/keyboard/emacs.js @@ -108,9 +108,8 @@ exports.handler.attach = function(editor) { editor.commands.addCommands(commands); exports.handler.platform = editor.commands.platform; editor.$emacsModeHandler = this; - require('../incremental_search'); - editor.setOption('useIncrementalSearch', true); - this.setupIncrementalSearch(editor, true); + if (!editor.getOption('useIncrementalSearch')) editor.setOption('useIncrementalSearch', true) + else this.setupIncrementalSearch(editor, true);; }; exports.handler.detach = function(editor) { @@ -487,5 +486,17 @@ exports.killRing = { } }; +require('../incremental_search'); +exports.handler.setupIncrementalSearch = function(editor, val) { + if (this.usesIncrementalSearch == val) return; + this.usesIncrementalSearch = val; + if (val) { + this.bindKey('C-s', 'iSearch'); + this.bindKey('C-r', 'iSearchBackwards'); + } else { + this.bindKey('C-s', "findnext"); + this.bindKey('C-r', "findprevious"); + } +} });