Properly handle move up zero lines in TerminalMenus. #38630
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Cc @timholy
Unfortunately #38489 wasn't quite correct in the case of a one element menu and at least one header line, as can be seen by running
This was quite mysterious until I realized that the current implementation relies on the corner case that
"\x1b[0A"
("move up zero lines") actually moves up one line. In fact the0
parameter means to use the default value, which for cursor up is one, see https://vt100.net/docs/vt510-rm/chapter4.html, section 4.3.3.This PR fixes moving up zero lines by conditionally doing nothing and removes a workaround related to this corner case. As an effect a one element menu is now drawn without a dummy empty line below it. This is not a regression from Julia 1.5, where a one element menu was an error.
Additionally I replaced the
"\x1b[999D"
control code ("move left 999 spaces") with a mundane carriage return. As far as I can tell that's the desired result.