xterm.js
xterm.js copied to clipboard
Resizing when writing causes text to disappear and spaces to appear
If not resizing when writing (now I can resize as I want and text is correct):
If resizing when writing:
Tried fitAddon.fit() and even terminal.resize(fitAddon.proposeDimensions()). Also tried to debounce to 500 ms with no luck.
Data is written by chunks as Uint8Array from ReadableStream.
Details
- Browser and browser version: Chrome 114.0.5735.133 (Official Build) (64-bit)
- OS version: Linux 5.15.114-2-MANJARO x86_64 GNU/Linux
- xterm.js version: 5.2.1
Steps to reproduce
- Call write periodically.
- Call resize.
@xReav3r any more details on how you're writing and what you mean by writing periodically? I can't reproduce this but it would be great to fix it.
Managed to simulate it here (just resize the window width under line width): https://codesandbox.io/s/kind-http-xkj3jt?file=/src/App.js&resolutionWidth=802&resolutionHeight=675
Do you mean how it goes like this when you make it really narrow?
Yes, but it just need to be narrower than line, even if it is one character, but looks like it depends on the text that goes before endline. In real usage I am streaming real terminal trought ReadableStream, where size of chunk is "random".
When resizing over line width everything is okay.
I have a similar bug with resizing. Everything is ok without text, but if i paste the text and zoom in to 175% it starts to duplicate and looks weird:
"xterm": "5.3.0",
"xterm-addon-attach": "0.9.0",
"xterm-addon-fit": "0.8.0"
useEffect(() => {
const terminal = new Terminal();
const attachAddon = new AttachAddon(ws);
const fitAddon = new FitAddon();
terminal.loadAddon(attachAddon);
terminal.loadAddon(fitAddon);
const sendResize = (cols: number, rows: number) => {
ws.readyState === WebSocket.OPEN &&
ws.send(
new Blob(
[
JSON.stringify({
type: 'resize',
cols,
rows,
}),
],
{ type: 'application/json' }
)
);
};
const doSendResize = () => sendResize(terminal.cols, terminal.rows);
ws.addEventListener('open', doSendResize);
terminal.open(notNull(terminalRef.current));
terminal.onResize((size) => sendResize(size.cols, size.rows));
const resizeObserver = new ResizeObserver(() => {
requestAnimationFrame(() => {
fitAddon.proposeDimensions();
fitAddon.fit();
});
});
resizeObserver.observe(notNull(terminalRef.current));
return () => {
resizeObserver.disconnect();
ws.removeEventListener('open', doSendResize);
terminal.dispose();
ws.close(1000);
};
}, []);
I also encountered the same problem. After the browser was scaled, due to the fact that the row height was not an integer when calculating rows, there was an error in the calculation. Finally, when calculating the total height of the container, there was a difference from the actual container height, resulting in some content being occluded
Any updates? Still relevant.