fix Enter key clearing selected text, fixes #1219

regressed in 7a479edc
This commit is contained in:
tophf 2021-04-02 07:12:44 +03:00
parent 8c160ed40c
commit 2d5788766a

View File

@ -70,7 +70,9 @@
if (found) { if (found) {
const target = $('.' + TARGET_CLASS); const target = $('.' + TARGET_CLASS);
const cm = target.CodeMirror; const cm = target.CodeMirror;
(cm || target).focus(); /* Since this runs in `keydown` event we have to delay focusing
* to prevent CodeMirror from seeing and handling the key */
setTimeout(() => (cm || target).focus());
if (cm) { if (cm) {
const {from, to} = cm.state.search.searchPos; const {from, to} = cm.state.search.searchPos;
cm.jumpToPos(from, to); cm.jumpToPos(from, to);