-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resizing not working on Svelte #3887
Comments
Can you clarify where the data loss is in the gif? |
The problem is that the text that goes outside the screen is not sent to the row below but just disappear. This is another example: Numerus.2022-07-06.14-43-13.mp4Another thing I noticed is that, even thought I call |
Some cleaner code: <script lang="ts">
import { onMount } from 'svelte';
import 'xterm/css/xterm.css';
import * as xterm from 'xterm';
import * as fit from 'xterm-addon-fit';
import ResizeObserver from 'svelte-resize-observer';
let terminalElement: HTMLElement;
let terminalController: xterm.Terminal;
let termFit: fit.FitAddon;
$: {
if (terminalController) {
// ...
}
}
function initalizeXterm() {
terminalController = new xterm.Terminal();
termFit = new fit.FitAddon();
terminalController.loadAddon(termFit);
terminalController.open(terminalElement);
termFit.fit();
terminalController.write('I am a terminal!');
terminalController.onData((e) => {
console.log(e);
})
}
onMount(async () => {
initalizeXterm();
})
function handleTermResize() {
if (termFit) {
termFit.fit();
console.log("Resizing!");
}
}
</script>
<!-- Actual terminal -->
<div
id="terminal"
bind:this="{terminalElement}"
/>
<!-- Resize observer -->
<div class="absolute top-0 bottom-0 left-0 right-0">
<ResizeObserver on:resize={handleTermResize}/>
</div> |
When this happens it means reflow isn't working properly which is controlled by this: xterm.js/src/common/buffer/Buffer.ts Lines 255 to 257 in 54cbbf6
Could you try debugging into that and checking what the values are? |
Debugging into that it looks like the function returns true. I created a basic repo so that you can test it yourself if you'd like: |
I tried to only use svelte and it also does not work. I used the same code as before and the same issue appear, so it has do to with svelte (or my code)! I also could not find any successful implementation of fitAddon with svelte online. |
This is an online example: |
Found the issue!! This happens because I do not have a '\n' at the end of the line! I have no clue why it works this way but now it started working! Check the REPL |
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes podman-desktop#501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
* fix: view logs not showing full screen height on load ### What does this PR do? Fixes the issue of the logs only showing half the screen rather than full. This is caused by the xterm package incorrectly loading and setting the height to half. Related bug: xtermjs/xterm.js#3887 ### Screenshot/screencast of this PR <!-- Please include a screenshot or a screencast explaining what is doing this PR --> ### What issues does this PR fix or reference? <!-- Please include any related issue from Podman Desktop repository (or from another issue tracker). --> Closes #501 ### How to test this PR? Use `yarn watch` and load up the logs on a container. It should now be full height. <!-- Please explain steps to reproduce --> Signed-off-by: Charlie Drage <charlie@charliedrage.com> * update Signed-off-by: Charlie Drage <charlie@charliedrage.com> * update 2 Signed-off-by: Charlie Drage <charlie@charliedrage.com> Signed-off-by: Charlie Drage <charlie@charliedrage.com>
Resizing causes the text to disappear on Svelte. This is a simple REPL you can try online:
https://svelte.dev/repl/49e256b936604e9ab94e357930891130?version=3.49.0
Ideally, it should work like this (React):
https://codesandbox.io/s/9szg9?file=/src/App
Old post
I'm trying to handle xterm resize in a desktop app (Tauri - Svelte - Vite), but resizing using
![Numerus-2022-07-06-11-36-01](https://user-images.githubusercontent.com/47280851/177520974-d4a87813-cebb-41b4-b9ce-e097a18e1983.gif)
fitAddon.fit()
causes loss of data and does not resize correctly:This is seems like an old issue fixed time ago:
#325 #616
This is basically my terminal component:
UPDATE: look my other comment for cleaner code
How to reproduce
With tauri prerequisites installed (https://tauri.app/v1/guides/getting-started/prerequisites) download my repo:
https://github.com/BearToCode/xterm-resize-not-working
Use
npm install
andnpm run tauri dev
.Details
Webview2: 103.0.1264.4
(Tauri on Windows 11)OS: Windows 10.0.22000 X64
(Windows 11)xterm@4.19.0
,xterm-addon-fit@0.5.0
The text was updated successfully, but these errors were encountered: