@@ -286,7 +286,18 @@ static int FindCommonPrefixLength(string leftStr, string rightStr)
286
286
287
287
// For screen readers, we are just comparing the previous and current buffer text
288
288
// (without colors) and only writing the differences.
289
- string currentBuffer = ParseInput ( ) ;
289
+ string parsedInput = ParseInput ( ) ;
290
+ StringBuilder buffer = new ( parsedInput ) ;
291
+
292
+ // Really simple handling of a status line: append it!
293
+ if ( ! string . IsNullOrEmpty ( _statusLinePrompt ) )
294
+ {
295
+ buffer . Append ( "\n " ) ;
296
+ buffer . Append ( _statusLinePrompt ) ;
297
+ buffer . Append ( _statusBuffer ) ;
298
+ }
299
+
300
+ string currentBuffer = buffer . ToString ( ) ;
290
301
string previousBuffer = _previousRender . lines [ 0 ] . Line ;
291
302
292
303
// In case the buffer was resized.
@@ -310,7 +321,7 @@ static int FindCommonPrefixLength(string leftStr, string rightStr)
310
321
{
311
322
// Buffers share a common prefix but previous buffer has additional content.
312
323
// Move cursor to where the difference starts, clear forward, and write the data.
313
- var diffPoint = ConvertOffsetToPoint ( commonPrefixLength ) ;
324
+ var diffPoint = ConvertOffsetToPoint ( commonPrefixLength , buffer ) ;
314
325
_console . SetCursorPosition ( diffPoint . X , diffPoint . Y ) ;
315
326
var changedData = currentBuffer . Substring ( commonPrefixLength ) ;
316
327
_console . Write ( "\x1b [0J" ) ;
@@ -325,7 +336,7 @@ static int FindCommonPrefixLength(string leftStr, string rightStr)
325
336
}
326
337
327
338
// If we had to wrap to render everything, update _initialY
328
- var endPoint = ConvertOffsetToPoint ( currentBuffer . Length ) ;
339
+ var endPoint = ConvertOffsetToPoint ( currentBuffer . Length , buffer ) ;
329
340
if ( endPoint . Y >= bufferHeight )
330
341
{
331
342
@@ -349,7 +360,7 @@ static int FindCommonPrefixLength(string leftStr, string rightStr)
349
360
_previousRender = renderData ;
350
361
351
362
// Calculate the coord to place the cursor for the next input.
352
- var point = ConvertOffsetToPoint ( _current ) ;
363
+ var point = ConvertOffsetToPoint ( _current , buffer ) ;
353
364
354
365
if ( point . Y == bufferHeight )
355
366
{
@@ -1327,8 +1338,12 @@ internal Point EndOfBufferPosition()
1327
1338
return ConvertOffsetToPoint ( _buffer . Length ) ;
1328
1339
}
1329
1340
1330
- internal Point ConvertOffsetToPoint ( int offset )
1341
+ internal Point ConvertOffsetToPoint ( int offset , StringBuilder buffer = null )
1331
1342
{
1343
+ // This lets us re-use the logic in the screen reader rendering implementation
1344
+ // where the status line is added to the buffer without modifying the locabl state.
1345
+ buffer ??= _buffer ;
1346
+
1332
1347
int x = _initialX ;
1333
1348
int y = _initialY ;
1334
1349
@@ -1337,7 +1352,7 @@ internal Point ConvertOffsetToPoint(int offset)
1337
1352
1338
1353
for ( int i = 0 ; i < offset ; i ++ )
1339
1354
{
1340
- char c = _buffer [ i ] ;
1355
+ char c = buffer [ i ] ;
1341
1356
if ( c == '\n ' )
1342
1357
{
1343
1358
y += 1 ;
@@ -1355,7 +1370,7 @@ internal Point ConvertOffsetToPoint(int offset)
1355
1370
1356
1371
// If cursor is at column 0 and the next character is newline, let the next loop
1357
1372
// iteration increment y.
1358
- if ( x != 0 || ! ( i + 1 < offset && _buffer [ i + 1 ] == '\n ' ) )
1373
+ if ( x != 0 || ! ( i + 1 < offset && buffer [ i + 1 ] == '\n ' ) )
1359
1374
{
1360
1375
y += 1 ;
1361
1376
}
@@ -1364,9 +1379,9 @@ internal Point ConvertOffsetToPoint(int offset)
1364
1379
}
1365
1380
1366
1381
// If next character actually exists, and isn't newline, check if wider than the space left on the current line.
1367
- if ( _buffer . Length > offset && _buffer [ offset ] != '\n ' )
1382
+ if ( buffer . Length > offset && buffer [ offset ] != '\n ' )
1368
1383
{
1369
- int size = LengthInBufferCells ( _buffer [ offset ] ) ;
1384
+ int size = LengthInBufferCells ( buffer [ offset ] ) ;
1370
1385
if ( x + size > bufferWidth )
1371
1386
{
1372
1387
// Character was wider than remaining space, so character, and cursor, appear on next line.
0 commit comments