mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-02-21 06:46:09 +08:00
Move the cursor to the beginning before printing right prompt
This makes the right prompt position independent of the width of the commandline, which prevents staircase effects. That means, with "X" standing in as a character that the terminal and fish disagree on: ``` > echo X rightprompt ``` will stay like that instead of creating a staircase like ``` > echo X rightpromp t> echo X rightpromp pt> echo X ``` and so on. The cursor still won't be *correct*, but it will be wrong in a less annoying way.
This commit is contained in:
parent
d3ceba107e
commit
0660ea5be7
@ -877,6 +877,9 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring
|
||||
|
||||
// Output any rprompt if this is the first line.
|
||||
if (i == 0 && right_prompt_width > 0) { //!OCLINT(Use early exit/continue)
|
||||
// Move the cursor to the beginning of the line first to be independent of the width.
|
||||
// This helps prevent staircase effects if fish and the terminal disagree.
|
||||
s_move(scr, 0, 0);
|
||||
s_move(scr, static_cast<int>(screen_width - right_prompt_width), static_cast<int>(i));
|
||||
set_color(highlight_spec_t{});
|
||||
s_write_str(scr, right_prompt.c_str());
|
||||
|
Loading…
x
Reference in New Issue
Block a user