From 3c13f13ae28083bedab1ed6ccb864c5853b24fba Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 29 Jun 2018 13:00:25 +0300 Subject: [PATCH] FF workaround for broken execCommand and getSelection closes #407 --- edit/global-search.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/edit/global-search.js b/edit/global-search.js index 2af7d4d4..d55923d9 100644 --- a/edit/global-search.js +++ b/edit/global-search.js @@ -96,6 +96,8 @@ onDOMready().then(() => { this._input.focus(); document.execCommand('selectAll', false, null); document.execCommand('delete', false, null); + // some versions of Firefox ignore the above + this._input.value = ''; }, case() { state.icase = !state.icase; @@ -535,7 +537,7 @@ onDOMready().then(() => { setActiveEditor(cm); const dialogFocused = state.dialog && state.dialog.contains(document.activeElement); - let sel = dialogFocused ? '' : getSelection().toString(); + let sel = dialogFocused ? '' : getSelection().toString() || cm && cm.getSelection(); sel = !sel.includes('\n') && !sel.includes('\r') && sel; if (sel) state.find = sel; @@ -546,6 +548,8 @@ onDOMready().then(() => { state.input.focus(); state.input.select(); document.execCommand('insertText', false, sel); + // some versions of Firefox ignore the above + state.input.value = sel; } state.input.focus();