Skip to content

Commit 39761f9

Browse files
authored
No need to clear lines when it's not a menu completion rendering (#3199)
1 parent 544f4bf commit 39761f9

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

PSReadLine/Completion.cs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -506,26 +506,26 @@ public void DrawMenu(Menu previousMenu, bool menuSelect)
506506
}
507507
}
508508

509-
// if the menu has moved, we need to clear the lines under it
510-
if (Top < PreviousTop)
509+
if (menuSelect)
511510
{
512-
// In either of the following two cases, we will need to move the cursor to the next line:
513-
// - if extra rows from previous menu were cleared, then we know the current line was erased
514-
// but the cursor was not moved to the next line.
515-
// - if 'CursorLeft != 0', then the rest of the last menu row was erased, but the cursor
516-
// was not moved to the next line.
517-
if (extraPreRowsCleared || console.CursorLeft != 0)
511+
// if the menu has moved, we need to clear the lines under it
512+
if (Top < PreviousTop)
518513
{
519-
// There are lines from the previous rendering that need to be cleared,
520-
// so we are sure there is no need to scroll.
521-
MoveCursorDown(1);
522-
}
514+
// In either of the following two cases, we will need to move the cursor to the next line:
515+
// - if extra rows from previous menu were cleared, then we know the current line was erased
516+
// but the cursor was not moved to the next line.
517+
// - if 'CursorLeft != 0', then the rest of the last menu row was erased, but the cursor
518+
// was not moved to the next line.
519+
if (extraPreRowsCleared || console.CursorLeft != 0)
520+
{
521+
// There are lines from the previous rendering that need to be cleared,
522+
// so we are sure there is no need to scroll.
523+
MoveCursorDown(1);
524+
}
523525

524-
Singleton.WriteBlankLines(PreviousTop - Top);
525-
}
526+
Singleton.WriteBlankLines(PreviousTop - Top);
527+
}
526528

527-
if (menuSelect)
528-
{
529529
RestoreCursor();
530530
console.CursorVisible = true;
531531
}

0 commit comments

Comments
 (0)