diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2022-10-24 23:22:42 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2022-10-24 23:22:42 -0700 |
commit | 5d93cd0a16dcfb54690141e836d7d9dfd8b19d27 (patch) | |
tree | 4876dafd220ac63e0152c18f56137a218d5fbac8 | |
parent | cd052fce5b5b92368689ab42a13f472c31d8493a (diff) | |
download | jp-hash-5d93cd0a16dcfb54690141e836d7d9dfd8b19d27.tar.gz jp-hash-5d93cd0a16dcfb54690141e836d7d9dfd8b19d27.tar.bz2 jp-hash-5d93cd0a16dcfb54690141e836d7d9dfd8b19d27.zip |
firefox: re-select replaced selection.
* firefox/jp-hash.js (jp_hash_edit): After replacing
the content of the text object, select that portion of
it which replaced the prior selection.
-rw-r--r-- | firefox/jp-hash.js | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/firefox/jp-hash.js b/firefox/jp-hash.js index 4eaa42d..4e76e99 100644 --- a/firefox/jp-hash.js +++ b/firefox/jp-hash.js @@ -109,7 +109,11 @@ async function jp_hash_edit(elem) let sel = elem.value.substring(start, end); let tail = elem.value.substring(end, len); - jphash(sel, (jph) => { elem.value = head + jph + tail; }); + jphash(sel, (jph) => { + elem.value = head + jph + tail; + elem.selectionStart = start; + elem.selectionEnd = start + jph.length; + }); } else { jphash(elem.value, (jph) => { elem.value = jph; }); } |