Skip to content

Commit 5c6025a

Browse files
40thievesmarijnh
authored andcommitted
[search addon] Capture keys for search-related commands in persistent dialog
1 parent 8eb1588 commit 5c6025a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

addon/search/search.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,21 @@
6262
value: deflt,
6363
selectValueOnOpen: true,
6464
closeOnEnter: false,
65-
onClose: function() { clearSearch(cm); }
65+
onClose: function() { clearSearch(cm); },
66+
onKeyDown: function(ev, query) {
67+
var cmd = CodeMirror.keyMap['default'][CodeMirror.keyName(ev)];
68+
if (cmd) {
69+
var nextSearchCmds = ['findNext', 'findPrev'];
70+
var searchCmds = ['find', 'findPersistent'];
71+
if (nextSearchCmds.indexOf(cmd) !== -1) {
72+
startSearch(cm, getSearchState(cm), query);
73+
CodeMirror.commands[cmd](cm);
74+
CodeMirror.e_stop(ev);
75+
} else if (searchCmds.indexOf(cmd) !== -1) {
76+
f(query, ev);
77+
}
78+
}
79+
}
6680
});
6781
}
6882

0 commit comments

Comments
 (0)