-
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
Reflow text on resize #1864
Reflow text on resize #1864
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wow nice, this looks very promising 👍
Few more remarks from my side:
|
Well at the very least we could iterate over all the markers and adjust them as appropriately.
xterm.js/src/common/CircularList.ts Lines 141 to 144 in 4375b3c
One optimization that comes to mind is to more manually control |
Would be great if we get it down to just one "cleanup step". Id expect it to be magnitudes faster and less growing with the amount of lines 😸 |
This messy but this drops 100000 scrollback reflow from 87 cols to 40 cols go from ~18 seconds to < 1 second, 10000 takes around 70ms
Just sped up reflow smaller greatly. I tried 2 solutions to optimize:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should fix the wide char thing before merging as it might affect a pretty big user base.
assert.equal(buffer.lines.get(i).translateToString(), ' '); | ||
} | ||
}); | ||
it('should transfer combined char data over to reflowed lines', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The emoji is actually a surrogate pair (which happens to be handled like a combined string currently, but not with upcoming the UTF32 buffer anymore). Would be better to test combining here with an accent like '`'.
We also need some wide char tests as they have that awkward "dangling cell" behavior (Have not seen tests with wide chars)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be better to test combining here with an accent like '`'.
Not sure what you mean here?
We also need some wide char tests as they have that awkward "dangling cell" behavior (Have not seen tests with wide chars)
I think these are covered by the wide tests now?
Ensure combined is cleared when shrinking and enlarging
@Tyriar Great job! My chinese lorem ipsum test is now working correctly, it does not add white spaces anymore. On minor thing I found: The cursor gets not moved, if its on a wrapped line. Not even sure what the right way to deal with it, whether it should move with the reflowing content or stay at its position. I think we can address this as soon as issues come in. Ready from my side. 👍 |
…ermjs/xterm.js#1864; we will wait until that messed is sorted out before ever upgrading xterm.js again: see xtermjs/xterm.js#1932 and
So I started working on the solution for reflow I designed in #622 (comment) and ran into some problems with dealing with how the escape sequences impact the buffer. It got me thinking, maybe reflow will be fast enough by just adjusting the whole buffer with the new buffer implementation. Instead of dealing with copying a bunch of strings like before or recording wrapping points, now we just need to copy data to and from a bunch of
ArrayBuffer
s and inserting or deleting extraBufferLine
s.I'm going to defer benchmarking until the todo list below is closer to done, but the results look good so far, along the lines of ~5-20ms for 1000 scrollback, definitely seems good enough to go ahead with. Also, if perf is an issue on less powerful machines or higher scrollbacks, there is always the option of debouncing resize.
Note that this only works when the TypedArray buffer is enabled.
Fixes #622 (finally)
Part of microsoft/vscode#23688
TODO
BufferLine
s to store more cells thanTerminal.cols
set
where appropriatePossible improvements in the future
BufferLine._data
unless it saves 50%+ memory, this would save a bunch of runtime inBufferLine.resize
in creating/gcing new/old arrays Don't resize down BufferLine._data unless it saves a significant amount of memory #1870Automated test on demo