@@ -170,10 +170,7 @@ private async Task<string> ReadLine(bool isCommandLine, CancellationToken cancel
170
170
int promptStartCol = initialCursorCol ;
171
171
int promptStartRow = initialCursorRow ;
172
172
173
- // The effective width of the console is 1 less than
174
- // Console.WindowWidth, all calculations should be
175
- // with respect to that
176
- int consoleWidth = Console . WindowWidth - 1 ;
173
+ int consoleWidth = Console . WindowWidth ;
177
174
178
175
if ( ( keyInfo . Modifiers & ConsoleModifiers . Alt ) == ConsoleModifiers . Alt ||
179
176
( keyInfo . Modifiers & ConsoleModifiers . Control ) == ConsoleModifiers . Control )
@@ -223,6 +220,13 @@ private async Task<string> ReadLine(bool isCommandLine, CancellationToken cancel
223
220
null ,
224
221
powerShell ) ;
225
222
223
+ if ( currentCompletion . CompletionMatches . Count == 0 )
224
+ {
225
+ // No completion matches, skip the rest
226
+ // TODO: Need to re-render on *NIX?
227
+ continue ;
228
+ }
229
+
226
230
int replacementEndIndex =
227
231
currentCompletion . ReplacementIndex +
228
232
currentCompletion . ReplacementLength ;
@@ -512,7 +516,8 @@ private int InsertInput(
512
516
int replaceLength = 0 ,
513
517
int finalCursorIndex = - 1 )
514
518
{
515
- int consoleWidth = Console . WindowWidth - 1 ;
519
+ // TODO: Right change?
520
+ int consoleWidth = Console . WindowWidth ;
516
521
int previousInputLength = inputLine . Length ;
517
522
518
523
int startCol = - 1 ;
@@ -566,28 +571,17 @@ private int InsertInput(
566
571
}
567
572
568
573
// Re-render affected section
569
- // TODO: Render this in chunks for perf
570
- for ( int i = insertIndex ;
571
- i < Math . Max ( inputLine . Length , previousInputLength ) ;
572
- i ++ )
573
- {
574
- if ( i < inputLine . Length )
575
- {
576
- Console . Write ( inputLine [ i ] ) ;
577
- }
578
- else
579
- {
580
- Console . Write ( ' ' ) ;
581
- }
582
-
583
- writeCursorCol ++ ;
574
+ Console . Write (
575
+ inputLine . ToString (
576
+ insertIndex ,
577
+ inputLine . Length - insertIndex ) ) ;
584
578
585
- if ( writeCursorCol == consoleWidth )
586
- {
587
- writeCursorCol = 0 ;
588
- Console . CursorTop += 1 ;
589
- Console . CursorLeft = 0 ;
590
- }
579
+ if ( inputLine . Length < previousInputLength )
580
+ {
581
+ Console . Write (
582
+ new string (
583
+ ' ' ,
584
+ previousInputLength - inputLine . Length ) ) ;
591
585
}
592
586
593
587
// Automatically set the final cursor position to the end
@@ -609,11 +603,6 @@ private int InsertInput(
609
603
finalCursorIndex ) ;
610
604
}
611
605
612
- //Console.Write(
613
- // inputLine.ToString(
614
- // insertIndex,
615
- // inputLine.Length - insertIndex));
616
-
617
606
// Return the updated cursor index
618
607
return finalCursorIndex != - 1 ? finalCursorIndex : inputLine . Length ;
619
608
}
0 commit comments