-
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
Reverse wraparound #2724
Reverse wraparound #2724
Conversation
Update: Eww, reverse wrap-around does some weird things on xterm - any cursor movement sequence does not respect grid borders anymore, instead the cursor wraps as well. Not sure why it was made like this, it leads to a totally different behavior for all of those sequences. DECAWM does not do this, from a "rule of least surprise" i'd call this behavior flawed. Ofc this is a bold statement since it seems to be an xterm feature originally. Still it changes the way the terminal content gets addressed, I think we should not follow that path. Suggestion, up for discussion:
This is more in line how DECAWM works and makes reverse wrap-around kinda the opposite/undo action. FYI: @Tyriar, @egmontkob |
This is what tmux does, and is probably the most reasonable behavior. |
@egmontkob Thx for your feedback. Yes I think so too, seems to be much more reasonable than altering the behavior of 50% of the common terminal sequences. Though I wonder why xterm did it this way in the first place (pros/cons compared to a stricter "DECAWM reverse") and whether there is some significant usage in the wild with that odd behavior. Not sure if it is worth to be brought up in terminal-wg... FYI: @textshell |
@Tyriar Done with the implementation and tests. Up for review. Btw, you can test the difference with the following:
|
Excitingly enough, @jerch has made this PR in response to my feature request for reverse-wraparound mode, which obviates me having to add mediocre implementation of it: xtermjs/xterm.js#2724
@jerch I don't see any difference with this branch and master when doing this? 😕 |
Oh thats weird. Maybe you are "holding it wrong" 😸 Here are the exact steps to repro the difference:
|
@jerch oh I ran |
src/InputHandler.ts
Outdated
* reverse wrap-around: | ||
* Our implementation deviates from xterm on purpose. Details: | ||
* - only previous soft NLs can be reversed (isWrapped=true) | ||
* - only works within scrollborders (top/bottom, left/right not yet supported) |
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.
Not yet supported? Do we need to note this in vt features?
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 dont think so, we dont support left/right scroll margins at all atm, it is still on the TODO list of missing vt features. The comment is more a reminder to cover it here as well once we implement it (which is abit more involved, as it needs to be respected in several vt commands, nothing to deal with here).
src/common/InputHandler.test.ts
Outdated
assert.equal(bufferService.buffer.x, 0); | ||
}); | ||
/* | ||
it.only('should not reverse outside of scroll margins', () => { |
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.
@Tyriar I cannot get this test working anymore without TestTerminal
, seems the scrollback is not respected at all. Any clue why?
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.
Yep, move it over here:
xterm.js/src/browser/Terminal.test.ts
Lines 1421 to 1430 in 45077d7
describe('Terminal InputHandler integration', () => { | |
function getLines(term: TestTerminal, limit: number = term.rows): string[] { | |
const res: string[] = []; | |
for (let i = 0; i < limit; ++i) { | |
res.push(term.buffer.lines.get(i)!.translateToString(true)); | |
} | |
return res; | |
} | |
// This suite cannot live in InputHandler unless Terminal.scroll moved into IBufferService |
Terminal
still owns scroll
, scroll
should probably live into BufferService
and then Terminal
reacts to it via an event. Created #2881 for this
I'll give this another review and hopefully merge next week 😃 |
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.
Works great and well tested 👌
There are a few things to consider, see @egmontkob's listing here: https://gitlab.gnome.org/GNOME/vte/issues/62
Basic implementation is done.
I had to disable theTurns out that xterm allows the last cell to be deleted if reverse wrap-around is set, otherwise not. Fixed._restrictCursor()
call, which is abit unfortunate. This needs further investigation and is prolly related to our weird way of handling pending wraps.Furthermore this PR revealed another bug - the last char before EOL is not shown under the "sticky" cursor, prolly the renderer does not take the char into account under the cursor in that position (data is correct in buffer).
Another bug: we currently dont clear cells to the right when early wraparound happens. Fixed.
TODO:
write reverse wrap-around xterm test case files?No comparison possible due to different behavior._restrictCursor()
behavior / scroll marginsisWrapped
flag (related isWrapped does not get lifted for longish bash commands #1882) --> Revise isWrapped behavior #2728Closes #2716.