aboutsummaryrefslogtreecommitdiffstats
path: root/firefox
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2022-10-24 23:22:42 -0700
committerKaz Kylheku <kaz@kylheku.com>2022-10-24 23:22:42 -0700
commit5d93cd0a16dcfb54690141e836d7d9dfd8b19d27 (patch)
tree4876dafd220ac63e0152c18f56137a218d5fbac8 /firefox
parentcd052fce5b5b92368689ab42a13f472c31d8493a (diff)
downloadjp-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.
Diffstat (limited to 'firefox')
-rw-r--r--firefox/jp-hash.js6
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; });
}