From add670212f71c3b8e11661eff6c5ea1ae430ce95 Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch Date: Sun, 11 Sep 2022 01:01:16 +0200 Subject: xP: remember buffer input selections --- xP/public/xP.js | 15 ++++++++++----- 1 file 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 => { -- cgit v1.2.3-70-g09d2