diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-09-11 01:01:16 +0200 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-09-11 01:01:53 +0200 |
commit | add670212f71c3b8e11661eff6c5ea1ae430ce95 (patch) | |
tree | 082b00d93dc19cd15f1098769267fafcda685775 /xP | |
parent | 95aa89ee97872caa98669f2e64e6b718ce5cf2e8 (diff) | |
download | xK-add670212f71c3b8e11661eff6c5ea1ae430ce95.tar.gz xK-add670212f71c3b8e11661eff6c5ea1ae430ce95.tar.xz xK-add670212f71c3b8e11661eff6c5ea1ae430ce95.zip |
xP: remember buffer input selections
Diffstat (limited to 'xP')
-rw-r--r-- | xP/public/xP.js | 15 |
1 files changed, 10 insertions, 5 deletions
diff --git a/xP/public/xP.js b/xP/public/xP.js index 4c740ba..e18d03b 100644 --- a/xP/public/xP.js +++ b/xP/public/xP.js @@ -242,13 +242,18 @@ rpc.addEventListener('BufferActivate', event => { return textarea.focus() - if (old !== undefined) + if (old !== undefined) { old.input = textarea.value + old.inputStart = textarea.selectionStart + old.inputEnd = textarea.selectionEnd + old.inputDirection = textarea.selectionDirection + } - if (b !== undefined) - textarea.value = b.input || '' - else - textarea.value = '' + textarea.value = '' + if (b !== undefined && b.input !== undefined) { + textarea.value = b.input + textarea.setSelectionRange(b.inputStart, b.inputEnd, b.inputDirection) + } }) rpc.addEventListener('BufferLine', event => { |