Nano zoom fix #14

This commit is contained in:
LukeGus
2024-12-05 19:58:24 -06:00
parent 474965835f
commit 0ed7d7a083
3 changed files with 88 additions and 88 deletions

View File

@@ -47,12 +47,6 @@ const App = () => {
}
});
const resizeTerminal = () => {
if (terminalRef.current) {
fitAddon.current.fit();
notifyServerOfResize();
}
};
const notifyServerOfResize = () => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
@@ -69,6 +63,13 @@ const App = () => {
}
};
const resizeTerminal = () => {
if (terminalRef.current) {
fitAddon.current.fit();
notifyServerOfResize();
}
};
resizeTerminal();
window.addEventListener('resize', resizeTerminal);
@@ -99,11 +100,15 @@ const App = () => {
socket.current.onmessage = (event) => {
console.log('Received message:', event.data);
terminal.current.write(event.data);
const parsedData = JSON.parse(event.data);
if (parsedData.type === 'process_closed') {
notifyServerOfResize();
try {
const parsedData = JSON.parse(event.data);
if (parsedData.type === 'process_closed') {
notifyServerOfResize();
} else {
terminal.current.write(event.data);
}
} catch (error) {
terminal.current.write(event.data)
}
};
@@ -119,21 +124,6 @@ const App = () => {
};
};
const notifyServerOfResize = () => {
if (socket.current && socket.current.readyState === WebSocket.OPEN) {
const { rows, cols } = terminal.current;
socket.current.send(
JSON.stringify({
type: 'resize',
rows,
cols,
height: terminalRef.current.offsetHeight,
width: terminalRef.current.offsetWidth,
})
);
}
};
const handleInputChange = (event, setState) => {
setState(event.target.value);
};
@@ -143,7 +133,6 @@ const App = () => {
if (!isSideBarHidden) {
setTimeout(() => {
fitAddon.current.fit();
notifyServerOfResize();
}, 100);
}
};