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

Column resize caching #386

Closed
wants to merge 5 commits into from
Closed

Column resize caching #386

wants to merge 5 commits into from

Conversation

imsnif
Copy link

@imsnif imsnif commented Nov 30, 2016

This is a quick fix for: #325

Rather than wrapping text, it just caches it temporarily and re-inserts it.
While not ideal, I think this is better than the current behaviour (just losing the text).
This is critical for one of our current projects, so if this is an acceptable (temporary?) fix, I'd be happy to write tests for it and make further changes to other integrated features (I'm new to this code base, so my apologies if I missed anything - would be happy to have anything pointed out to me).

Thanks!

@@ -2883,14 +2889,18 @@ Terminal.prototype.resize = function(x, y) {
i = this.lines.length;
while (i--) {
while (this.lines[i].length < x) {
this.lines[i].push(ch);
this.lineCache[i] = this.lineCache[i] || []
Copy link
Member

@Tyriar Tyriar Nov 30, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for putting out the PR! Unfortunately I don't think this will work as a temporary fix because this.lines frequently gets rows in the middle of the array removed/modified and also when the scrollback limit is reached, big chunks of the array are removed from the start. Covering all the cases for keeping lineCache in sync would probably be more difficult than a proper fix 😛 it could also potentially introduce performance issues.

I think a good temporary fix for this is to not remove the characters from this.lines at all, but instead only materialize up to this.cols characters from within this.refresh.

@imsnif
Copy link
Author

imsnif commented Dec 1, 2016

Okay @Tyriar - I see what you mean. I actually had such a feeling, but was lacking in any other direction to fix this. :)
So I went with your suggestion: specifically not removing characters from this.lines when shrinking. this.refresh already seems to do the job of materializing up to this.cols - this fixes it for me. What do you think?

@Tyriar
Copy link
Member

Tyriar commented Dec 1, 2016

I'm kind of surprised that's all this needed. @parisk do you know if there would be any unintended side effects to removing this column trimming code from resize?

@parisk
Copy link
Contributor

parisk commented Dec 5, 2016

Thanks for your contribution @imsnif! I just ran the demo on your branch and after reducing the number of columns text would just vanish, instead of wrapping.

If we get this working and apply some tests, we can definitely merge the request 👍 .

@imsnif
Copy link
Author

imsnif commented Dec 6, 2016

@parisk - we thought this could be a temporary fix for the problem, seeing as while it does not wrap the text, it does not "swallow" it either (as is the case right now). So while reducing the number of columns makes the text vanish, it comes back when you increase them again. It's not an ideal situation, but in my opinion it's better than the current behaviour. What do you think?

Other than that, I'm currently working on implementing a proper "wrapping" solution, but I'm not sure I'll have the time for it. If I will, I plan on doing a separate PR.

Copy link
Member

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine to ship as is, probably in 2.3.0 would be better so we can work out any issues if they come through in dogfooding.

Copy link
Contributor

@parisk parisk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to fix the wrapping issue before moving forward, as the end user has no clue on why these characters get vanished.

@parisk
Copy link
Contributor

parisk commented Dec 8, 2016

I think it's 👍 to postpone this until 2.3.0, to make sure we ship a good experience to the end user.

Whether which of these two experiences is best for the end user IMO is subjective, so let's just stick on fixing this the right way.

@imsnif as this is an important issue not only for you, but for other xterm.js users as well (our company including!) what can we do to help you as much as possible with moving forward with the full solution?

@imsnif
Copy link
Author

imsnif commented Dec 8, 2016

@parisk - I basically have a working version with line wrapping that I need to clean up locally. I'm currently writing some tests and then will do some refactoring before issuing another PR.
The main thing I need your input on is whether it will be fine to mark characters as being wrapped.
As in - right now (as I understand it) characters in the terminal are marked by an array of three items (eg. [ 131840, '1', 1 ])
My implementation will add a fourth item to mark whether the character is wrapped or not (eg. [ 131840, '1', 1, 'wrapped' ]). This is necessary, because these characters must be identified in order to distinguish between them and non-wrapped characters when resizing. Will this change be acceptable? (I can go into further detail if needed, or just discuss it as part of the next PR in a few days).

@Tyriar
Copy link
Member

Tyriar commented Dec 8, 2016

@imsnif why does resizing need to know if they're wrapped or not? What is the performance impact of not keeping a wrapped flag in on the characters?

@imsnif
Copy link
Author

imsnif commented Dec 8, 2016

@Tyriar - I'm using the wrapped flag on the characters in order to know whether they should be 'unwrapped' when the terminal is expanded.

@imsnif imsnif mentioned this pull request Dec 12, 2016
@imsnif
Copy link
Author

imsnif commented Dec 12, 2016

Closing this in favour of: #404

@imsnif imsnif closed this Dec 12, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants