From 5d93cd0a16dcfb54690141e836d7d9dfd8b19d27 Mon Sep 17 00:00:00 2001 From: Kaz Kylheku Date: Mon, 24 Oct 2022 23:22:42 -0700 Subject: 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. --- firefox/jp-hash.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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; }); } -- cgit v1.2.3