[pve-devel] [PATCH v2] fix #6223: fit terminal after 'OK' message
Dominik Csapak
d.csapak at proxmox.com
Mon Apr 7 10:25:09 CEST 2025
instead of simply waiting 250ms after we send the credentials, wait
until after the server responded with 'OK' to fit the terminal size.
Execute after the next frame, by using requestAnimationFrame twice. (One
for the current frame and one for the next), to show terminal content as
soon as possible.
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
changes from v1:
* use requestAnimationFrame instead of setTimeout with arbitrary delay
xterm.js/src/main.js | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/xterm.js/src/main.js b/xterm.js/src/main.js
index 289032c..902a1c3 100644
--- a/xterm.js/src/main.js
+++ b/xterm.js/src/main.js
@@ -222,6 +222,12 @@ function runTerminal() {
if (answer[0] === 79 && answer[1] === 75) { // "OK"
updateState(states.connected);
term.write(answer.slice(2));
+
+ // delay initial focus and resize to after next frame
+ requestAnimationFrame(() => requestAnimationFrame(() => {
+ term.focus();
+ fitAddon.fit();
+ }));
} else {
socket.close();
}
@@ -247,12 +253,6 @@ function runTerminal() {
});
socket.send(PVE.UserName + ':' + ticket + "\n");
-
- // initial focus and resize
- setTimeout(function() {
- term.focus();
- fitAddon.fit();
- }, 250);
}
function getLxcStatus(callback) {
--
2.39.5
More information about the pve-devel
mailing list