Typing in the character 'f' displays an extra space #5155
-
When I type the character 'f' into the terminal it displays 'f '. So, when I type 'asdfh', for example, I expect to see 'asdfh'. Unfortunately, I instead see 'asdf h'. However, when console logging the 'f' character before it is written, I do not see the extra space. I also tried hard coding the write, via This is only happening to me with the letter 'f' so far. Here is the code I am working with:
Details
Also note that I have the following versions for react/next:
Steps to reproduce
|
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 5 replies
-
I have literally the same OS and browser here, but cannot repro with our demo. My guess is, that somehow your project setup makes things up. Isnt nextjs used for serverside rendering? If you use serverside rendering - this never gonna work properly with xtermjs, unless those serverside DOM shims implement an almost fully working DOM abstraction. |
Beta Was this translation helpful? Give feedback.
-
I'm skeptical it's a nextjs thing because I'm using client side code to render it with UseEffect. That being said I'll be doing some further testing on this to confirm, especially looking into hydration. I'll also test on a vite react app (I should really have done this instead of next since I'm not really utilizing the server side rendering features of next) to see if I get the same effect. Will post updates as I get through these tests. |
Beta Was this translation helpful? Give feedback.
-
Same code fails in a react vite app. For reproduction, I did the following steps:
Code for App.tsx:
Same result occurs. Only happens to the character 'f' (not even 'F'). I feel like this test probably means that it's not a result of the other packages I had in my nextjs project or next itself. It could also be I am not properly writing to the terminal - I just picked up this library, so it's very possible there's just something wrong with my code above. I will still look into hydration to be extra sure, but to me this is looking like something going wrong with xterm. Unless React framework variants aren't supported? Edit: |
Beta Was this translation helpful? Give feedback.
-
Yup, so in my nextjs project I am can confirm I am using client side rendering as my page.tsx file (which is the parent of all components) utilizes client side code like UseState and UseEffect. Furthermore, I have marked this file with 'use client'. If I remove this marking, I am met with the following error:
And from my understanding of nextjs, this means that no server side rendering is taking place. So, ignore my hydration point earlier, as that's not even occurring here. |
Beta Was this translation helpful? Give feedback.
-
Can you check on xtermjs.org, if it happens there too for you? Also maybe use newest version of xtermjs, which is 5.5.0. Beside that - I have no clue, whats going on. Can you step-debug things from 'f' input down to terminal output? |
Beta Was this translation helpful? Give feedback.
-
The strange behavior does not happen on the site for me. I'll try updating the version and see what happens. If that's still not working I can looking into step-debugging. |
Beta Was this translation helpful? Give feedback.
-
We're not experts in react so if you can't provide a repro case using the plain API it's not very actionable on our end. Chances are, like in the past with similar issues, this is probably related to one of the framework lifecycle events messing with things. |
Beta Was this translation helpful? Give feedback.
-
This bug occurs in vanilla JS/HTML projects too (I believe what I have below is an example of the plain API, since it's essentially an extension of your getting started example - the only difference is I'm using CDNs instead of node modules). my index.html file:
main.js:
I ran I'd appreciate it if you could re-open the issue. I will add more information from my debugging when I have a chance to get to it, but unless I'm missing something, I think my testing shows this is an issue with xterm. |
Beta Was this translation helpful? Give feedback.
-
Yes I can repro with firefox v130 and the DOM renderer. Looks like a browser bug to me, older FF versions (98 & 123) work as expected. Also the gap is not an SP, but a single 'f' being rendered too wide. Prolly some issue with the metrics calc in FF 130 for 'f'. Only tested under ubuntu 22 LTS, thus idk if this is an ubuntu/linux only issue or affects all platforms for FF 130. Edit: wc=term._core._renderService._renderer._value._widthCache
wc.get('d', false, false)
9
wc.get('e', false, false)
9
wc.get('f', false, false)
4.5
wc.get('g', false, false)
9 Edit2:
Prolly a better fix would be to find a way to measure chars not by simply stacking them up in a row. |
Beta Was this translation helpful? Give feedback.
Yes I can repro with firefox v130 and the DOM renderer. Looks like a browser bug to me, older FF versions (98 & 123) work as expected.
Also the gap is not an SP, but a single 'f' being rendered too wide. Prolly some issue with the metrics calc in FF 130 for 'f'. Only tested under ubuntu 22 LTS, thus idk if this is an ubuntu/linux only issue or affects all platforms for FF 130.
Edit:
Yupp the char measuring is wrong:
Edit2:
Its a ligature issue - the newer FF version treats ff as a ligature merging 2 f into a single sma…