@@ -445,15 +445,8 @@ public void DrawMenu(Menu previousMenu, bool menuSelect)
445445 SaveCursor ( ) ;
446446 }
447447
448- // Move cursor to the start of the first line after our input.
449- var bufferEndPoint = Singleton . ConvertOffsetToPoint ( Singleton . _buffer . Length ) ;
450- console . SetCursorPosition ( bufferEndPoint . X , bufferEndPoint . Y ) ;
451- // Top must be initialized before calling AdjustForPossibleScroll, otherwise
452- // on the last line of the buffer, the scroll operation causes Top to point
453- // past the buffer, which in turn causes the menu to be printed twice.
454- this . Top = bufferEndPoint . Y + 1 ;
455- AdjustForPossibleScroll ( 1 ) ;
456- MoveCursorDown ( 1 ) ;
448+ PreviousTop = Top ;
449+ MoveCursorToStartDrawingPosition ( console ) ;
457450
458451 var bufferWidth = console . BufferWidth ;
459452 var columnWidth = this . ColumnWidth ;
@@ -514,7 +507,7 @@ public void DrawMenu(Menu previousMenu, bool menuSelect)
514507 }
515508
516509 // if the menu has moved, we need to clear the lines under it
517- if ( bufferEndPoint . Y < PreviousTop )
510+ if ( Top < PreviousTop )
518511 {
519512 // In either of the following two cases, we will need to move the cursor to the next line:
520513 // - if extra rows from previous menu were cleared, then we know the current line was erased
@@ -528,11 +521,9 @@ public void DrawMenu(Menu previousMenu, bool menuSelect)
528521 MoveCursorDown ( 1 ) ;
529522 }
530523
531- Singleton . WriteBlankLines ( PreviousTop - bufferEndPoint . Y ) ;
524+ Singleton . WriteBlankLines ( PreviousTop - Top ) ;
532525 }
533526
534- PreviousTop = bufferEndPoint . Y ;
535-
536527 if ( menuSelect )
537528 {
538529 RestoreCursor ( ) ;
@@ -797,7 +788,7 @@ private void PossibleCompletionsImpl(CommandCompletion completions, bool menuSel
797788 }
798789 else
799790 {
800- menu . DrawMenu ( null , menuSelect : false ) ;
791+ menu . DrawMenu ( null , menuSelect : false ) ;
801792 InvokePrompt ( key : null , arg : _console . CursorTop ) ;
802793 }
803794 }
@@ -879,7 +870,6 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions)
879870
880871 if ( topAdjustment != 0 )
881872 {
882- menu . Top += topAdjustment ;
883873 menu . DrawMenu ( null , menuSelect : true ) ;
884874 }
885875 if ( topAdjustment > 0 )
@@ -963,7 +953,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions)
963953 {
964954 var newMenu = menuStack . Pop ( ) ;
965955
966- newMenu . DrawMenu ( menu , menuSelect : true ) ;
956+ newMenu . DrawMenu ( menu , menuSelect : true ) ;
967957 previousSelection = - 1 ;
968958
969959 menu = newMenu ;
@@ -1025,7 +1015,7 @@ private void MenuCompleteImpl(Menu menu, CommandCompletion completions)
10251015 {
10261016 var newMenu = CreateCompletionMenu ( newMatches ) ;
10271017
1028- newMenu . DrawMenu ( menu , menuSelect : true ) ;
1018+ newMenu . DrawMenu ( menu , menuSelect : true ) ;
10291019 previousSelection = - 1 ;
10301020
10311021 // Remember the current menu for when we see Backspace.
0 commit comments