From 5c6025a337ff2964f7af29dffe25b4714e8516a4 Mon Sep 17 00:00:00 2001 From: Alasdair Smith Date: Fri, 3 Jun 2016 12:29:20 +0100 Subject: [PATCH] [search addon] Capture keys for search-related commands in persistent dialog --- addon/search/search.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/addon/search/search.js b/addon/search/search.js index e6b4f85a05..0f5d941889 100644 --- a/addon/search/search.js +++ b/addon/search/search.js @@ -62,7 +62,21 @@ value: deflt, selectValueOnOpen: true, closeOnEnter: false, - onClose: function() { clearSearch(cm); } + onClose: function() { clearSearch(cm); }, + onKeyDown: function(ev, query) { + var cmd = CodeMirror.keyMap['default'][CodeMirror.keyName(ev)]; + if (cmd) { + var nextSearchCmds = ['findNext', 'findPrev']; + var searchCmds = ['find', 'findPersistent']; + if (nextSearchCmds.indexOf(cmd) !== -1) { + startSearch(cm, getSearchState(cm), query); + CodeMirror.commands[cmd](cm); + CodeMirror.e_stop(ev); + } else if (searchCmds.indexOf(cmd) !== -1) { + f(query, ev); + } + } + } }); }