mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Avoid code duplication relating to screen clearning in s_update.
This commit is contained in:
parent
c9a77bb474
commit
7448e7825f
1 changed files with 7 additions and 10 deletions
|
@ -699,17 +699,21 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now actually output stuff.
|
// Now actually output stuff.
|
||||||
for (; j < o_line.size(); j++) {
|
for (; ; j++) {
|
||||||
|
bool done = j >= o_line.size();
|
||||||
|
// Clear the screen if we have not done so yet.
|
||||||
// If we are about to output into the last column, clear the screen first. If we clear
|
// If we are about to output into the last column, clear the screen first. If we clear
|
||||||
// the screen after we output into the last column, it can erase the last character due
|
// the screen after we output into the last column, it can erase the last character due
|
||||||
// to the sticky right cursor. If we clear the screen too early, we can defeat soft
|
// to the sticky right cursor. If we clear the screen too early, we can defeat soft
|
||||||
// wrapping.
|
// wrapping.
|
||||||
if (j + 1 == (size_t)screen_width && should_clear_screen_this_line &&
|
if (should_clear_screen_this_line && !has_cleared_screen
|
||||||
!has_cleared_screen) {
|
&& (done || j + 1 == (size_t)screen_width)) {
|
||||||
s_move(scr, current_width, (int)i);
|
s_move(scr, current_width, (int)i);
|
||||||
s_write_mbs(scr, clr_eos);
|
s_write_mbs(scr, clr_eos);
|
||||||
has_cleared_screen = true;
|
has_cleared_screen = true;
|
||||||
}
|
}
|
||||||
|
if (done)
|
||||||
|
break;
|
||||||
|
|
||||||
perform_any_impending_soft_wrap(scr, current_width, (int)i);
|
perform_any_impending_soft_wrap(scr, current_width, (int)i);
|
||||||
s_move(scr, current_width, (int)i);
|
s_move(scr, current_width, (int)i);
|
||||||
|
@ -719,13 +723,6 @@ static void s_update(screen_t *scr, const wcstring &left_prompt, const wcstring
|
||||||
current_width += width;
|
current_width += width;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the screen if we have not done so yet.
|
|
||||||
if (should_clear_screen_this_line && !has_cleared_screen) {
|
|
||||||
s_move(scr, current_width, (int)i);
|
|
||||||
s_write_mbs(scr, clr_eos);
|
|
||||||
has_cleared_screen = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool clear_remainder = false;
|
bool clear_remainder = false;
|
||||||
// Clear the remainder of the line if we need to clear and if we didn't write to the end of
|
// Clear the remainder of the line if we need to clear and if we didn't write to the end of
|
||||||
// the line. If we did write to the end of the line, the "sticky right edge" (as part of
|
// the line. If we did write to the end of the line, the "sticky right edge" (as part of
|
||||||
|
|
Loading…
Reference in a new issue