-
Notifications
You must be signed in to change notification settings - Fork 83
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
Avoid using CSI S sequence for scroll down #577
Conversation
@tompng Do you know anything about these? |
I think this fix is good 👍
|
Reline::IOGate.move_cursor_down(@rest_height) | |
Reline::IOGate.scroll_down(val - @rest_height) |
The meaning of the method is a bit changed, but I think adding a comment (limitation that ANSI.scroll_down only works when cursor is at the bottom) is enough.
Why it only happens in VS Code terminal
ANSI escape sequence has scroll-range setting.
If you run this code
# Before running this code, clear the screen with ctrl + l or command + k
use_csi_s = true # or false
scroll_range = 3..8 # or 1..8
print "\e[H" # move cursor to first row of the screen
print "\e[J" # clear screen
(1..10).each { |y| puts y }
print "\e[#{scroll_range.begin};#{scroll_range.end}r" # set scroll range
if use_csi_s
print "\e[3S" # scroll down 3 rows using CSI+S
else
print "\e[8H\n\n\n" # \n at the bottom of scroll range will also scroll down
end
print "\e[r" # rest scroll range
print "\e[11H" # move cursor to row 11
You will get this.
1
2
6 # ← scroll range start
7 #
8 #
#
#
# ← scroll range end
9
10
The difference happens when scroll range is set to 1..y
. (default is 1..screen_height
)
VS Code terminal seems to be doing:
- Scrolling with
\n
acts like scroll range is set to-infinity..y
- Scrolling with
CSI+S
acts like scroll range is set to1..y
Other terminal emulators(Terminal, iTerm, Alacritty) seems to be doing:
- Acts like scroll range is set to
-infinity..y
in both\n
andCSI+S
I don't know which behavior is correct. (I like VSCode's behavior)
Thanks for the explanation!
I did get the result. But should it be different depending on |
Sorry I forgot to write this.
But the difference is in the scroll buffer. |
Little good difference csi_s.mp4When you clear the screen using |
After reading PowerShell/PSReadLine#724, I suspected that the use of CSI S sequence for scroll down is also the cause of #576. So I swapped it with just writing
\n
(inspired by PowerShell/PSReadLine#790), and it seems to work.However, I couldn't find further information on how using the CSI S sequence would cause the problem and why it only happens in VS Code terminal. So I'm not sure if this is the best fix for the problem.
This seems to fix #576