Skip to content
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

FitAddon resizes incorrectly #4841

Open
SquitchYT opened this issue Oct 11, 2023 · 12 comments
Open

FitAddon resizes incorrectly #4841

SquitchYT opened this issue Oct 11, 2023 · 12 comments
Labels
area/addon/fit type/bug Something is misbehaving

Comments

@SquitchYT
Copy link
Contributor

Details

  • Browser and browser version: WebKit
  • OS version: Linux
  • xterm.js version: 5.3.0 (fitAddon: 0.8.0)

Steps to reproduce

let fitAddon = new FitAddon();
term.loadAddon(fitAddon);
fitAddon.fit();

The resized dimension do not take all the available space, instead, I need to use this code to use all the available space:

let fitAddon = new FitAddon();
term.loadAddon(fitAddon);
let proposedDimensions = fitAddon.proposeDimensions();
term.resize(proposedDimensions.cols + 1, proposedDimensions.rows + 1);
@SquitchYT SquitchYT changed the title FitAddon resize incorrectly FitAddon resizes incorrectly Oct 11, 2023
@bajrangCoder
Copy link

Yeah , i am also facing same

#4853

@Tyriar Tyriar added type/bug Something is misbehaving area/addon/fit labels Oct 30, 2023
@tisilent
Copy link
Contributor

tisilent commented Oct 31, 2023

@Tyriar Is it feasible to add autoResize as an option to FitAddin?

Wrong understanding.

@tisilent
Copy link
Contributor

tisilent commented Oct 31, 2023

scrollbarWidth? 😏

@akteigland
Copy link

akteigland commented Nov 1, 2023

I just ran into this. In my case I was calling fit before terminal.open()
The following code works for me:

const terminal = new Terminal();
const fitAddon = new FitAddon();
terminal.loadAddon(fitAddon);
terminal.open(myHTMLRef);
fitAddon.fit();

@jerch
Copy link
Member

jerch commented Nov 3, 2023

Cant repro that.

Still there is a chance though, that dimension calc might have slightly changed due to #4366, which switched from float to integer measuring of the reference char for the cell dimension.

@tisilent
Copy link
Contributor

I can repro ..........

@tisilent
Copy link
Contributor

tisilent commented Dec 19, 2023

issue
fit1

fit2

@jerch height 100%, I'm not sure why it was resized, there's no additional code.
Create a new tab, access the app, and this will happen. Refresh will work fine.

@jerch
Copy link
Member

jerch commented Dec 19, 2023

@tisilent As far as I see .fit() should not change pixel dimensions of the enclosing element at all. All it does - it calcs the maximum rows&cols still fitting into the given dimensions and alters the rows/cols values on the terminal object to those values. Then with the next render cycle it may draw more empty lines to the bottom (thats for the initial terminal state, where data does not fill up the rows yet).
My guess here - the empty rows are in fact higher, than calculated by the fit addon. At least with the DOM renderer this may lead to a dimension increase.
Is this from the demo page? With the DOM renderer?

@tisilent
Copy link
Contributor

@jerch This is a small tool. It's using Dom renderer.
Mainly after refreshing, it works normally.
I suspect it may be related to the browser.
Tomorrow I will go to that device to make a GIF.

@cx690
Copy link

cx690 commented Jan 8, 2024

same problem, look like term.resize bug, columns set 80 will be ok, set 90 will error.

@carolin-violet
Copy link

carolin-violet commented Jan 29, 2024

i use a setTimeout to resolve this problem,when i directly use proposeDimensions, it is undefined. i am confused

let fitAddon = new FitAddon();
term.loadAddon(fitAddon);
setTimeout(() => {
  let proposedDimensions = fitAddon.proposeDimensions();
  term.resize(proposedDimensions.cols + 1, proposedDimensions.rows + 1);
}, 2000)

@jerch
Copy link
Member

jerch commented Jan 29, 2024

@carolin-violet proposeDimensions is undefined if you try to call it before the terminal element has a DOM representation. Plz make sure to call it after calling Terminal.open(your_terminal_element). Beside preparing the terminal element itself, the open places several more elements into the DOM, that are needed for proper runtime size measuring. Without those, the measuring literally points into nothing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/addon/fit type/bug Something is misbehaving
Projects
None yet
Development

No branches or pull requests

8 participants