Skip to content

Commit 25c7515

Browse files
committed
Reduce side effects on options in screen reader mode
We don't need to disable predictions or the continuation prompt in the options, since with tests we can verify the few places we need to check.
1 parent c39f93e commit 25c7515

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

PSReadLine/Cmdlets.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,12 +151,6 @@ public class PSConsoleReadLineOptions
151151

152152
public const HistorySaveStyle DefaultHistorySaveStyle = HistorySaveStyle.SaveIncrementally;
153153

154-
/// <summary>
155-
/// The predictive suggestion feature is disabled by default.
156-
/// TODO: This no longer appears to be true.
157-
/// </summary>
158-
public const PredictionSource DefaultPredictionSource = PredictionSource.None;
159-
160154
public const PredictionViewStyle DefaultPredictionViewStyle = PredictionViewStyle.InlineView;
161155

162156
/// <summary>

PSReadLine/Options.cs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,6 @@ private void SetOptionsInternal(SetPSReadLineOption options)
188188
if (options._enableScreenReaderMode.HasValue)
189189
{
190190
Options.ScreenReaderModeEnabled = options.EnableScreenReaderMode;
191-
192-
if (Options.ScreenReaderModeEnabled)
193-
{
194-
// Disable prediction for better accessibility.
195-
Options.PredictionSource = PredictionSource.None;
196-
// Disable continuation prompt as multi-line is not available.
197-
Options.ContinuationPrompt = "";
198-
}
199191
}
200192
}
201193

PSReadLine/Render.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,10 @@ static int FindCommonPrefixLength(string leftStr, string rightStr)
286286

287287
// For screen readers, we are just comparing the previous and current buffer text
288288
// (without colors) and only writing the differences.
289+
//
290+
// Note that we don't call QueryForSuggestion() which is the only
291+
// entry into the prediction logic, so while it could be enabled, it
292+
// won't do anything in this rendering implementation.
289293
string parsedInput = ParseInput();
290294
StringBuilder buffer = new(parsedInput);
291295

@@ -1348,7 +1352,9 @@ internal Point ConvertOffsetToPoint(int offset, StringBuilder buffer = null)
13481352
int y = _initialY;
13491353

13501354
int bufferWidth = _console.BufferWidth;
1351-
var continuationPromptLength = LengthInBufferCells(Options.ContinuationPrompt);
1355+
var continuationPromptLength = Options.ScreenReaderModeEnabled
1356+
? 0
1357+
: LengthInBufferCells(Options.ContinuationPrompt);
13521358

13531359
for (int i = 0; i < offset; i++)
13541360
{
@@ -1400,7 +1406,10 @@ private int ConvertLineAndColumnToOffset(Point point)
14001406
int y = _initialY;
14011407

14021408
int bufferWidth = _console.BufferWidth;
1403-
var continuationPromptLength = LengthInBufferCells(Options.ContinuationPrompt);
1409+
var continuationPromptLength = Options.ScreenReaderModeEnabled
1410+
? 0
1411+
: LengthInBufferCells(Options.ContinuationPrompt);
1412+
14041413
for (offset = 0; offset < _buffer.Length; offset++)
14051414
{
14061415
// If we are on the correct line, return when we find

test/UnitTestReadLine.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -644,7 +644,9 @@ private void TestSetup(TestConsole console, KeyMode keyMode, params KeyHandler[]
644644
PSConsoleReadLine.SetOptions(colorOptions);
645645

646646
// Cache the continuation prompt length for use in tests
647-
_continuationPromptLength = PSConsoleReadLine.GetOptions().ContinuationPrompt.Length;
647+
_continuationPromptLength = ScreenReaderModeEnabled
648+
? 0
649+
: PSConsoleReadLine.GetOptions().ContinuationPrompt.Length;
648650

649651
if (!_oneTimeInitCompleted)
650652
{

0 commit comments

Comments
 (0)