File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -846,6 +846,8 @@ private void UpdateFromHistory(HistoryMoveCursor moveCursor)
846
846
}
847
847
_buffer . Clear ( ) ;
848
848
_buffer . Append ( line ) ;
849
+ // Deletes the whole line (from start of line)
850
+ SafeRender ( "\x1b [K" , 0 ) ;
849
851
850
852
switch ( moveCursor )
851
853
{
@@ -864,7 +866,8 @@ private void UpdateFromHistory(HistoryMoveCursor moveCursor)
864
866
}
865
867
866
868
using var _ = _prediction . DisableScoped ( ) ;
867
- Render ( ) ;
869
+ // Renders the line and re-adjusts the cursor to account for the above options
870
+ SafeRender ( line , cursorBefore : null , cursorAfter : _current ) ;
868
871
}
869
872
870
873
private void SaveCurrentLine ( )
Original file line number Diff line number Diff line change @@ -218,7 +218,7 @@ private void RenderWithPredictionQueryPaused()
218
218
Render ( ) ;
219
219
}
220
220
221
- private void SafeRender ( string s , int ? cursor = null )
221
+ private void SafeRender ( string s , int ? cursorBefore = null , int ? cursorAfter = null )
222
222
{
223
223
// Render as usual if we're not supporting a screen reader
224
224
if ( ! _singleton . Options . ScreenReader )
@@ -227,13 +227,17 @@ private void SafeRender(string s, int? cursor = null)
227
227
return ;
228
228
}
229
229
230
- // Move the cursor if we have to
231
- if ( cursor . HasValue )
232
- MoveCursor ( cursor . Value ) ;
230
+ // Many commands will need the cursor set before writing
231
+ if ( cursorBefore . HasValue )
232
+ MoveCursor ( cursorBefore . Value ) ;
233
233
234
234
// Directly write without re-rendering
235
235
// This means using ANSI escapes for movement
236
236
_console . Write ( s ) ;
237
+
238
+ // Some commands adjust the cursor after writing
239
+ if ( cursorAfter . HasValue )
240
+ MoveCursor ( cursorAfter . Value ) ;
237
241
}
238
242
239
243
private void Render ( )
You can’t perform that action at this time.
0 commit comments