Skip to content

Commit 876fdb0

Browse files
committed
Fix tznind feedback
1 parent a0b2a29 commit 876fdb0

File tree

2 files changed

+17
-17
lines changed

2 files changed

+17
-17
lines changed

Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiRequestScheduler.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class AnsiRequestScheduler
3535
/// queued).
3636
/// </para>
3737
/// </summary>
38-
private readonly ConcurrentDictionary<string?, DateTime> _lastSend = new ();
38+
private readonly ConcurrentDictionary<string, DateTime> _lastSend = new ();
3939

4040
/// <summary>
4141
/// Number of milliseconds after sending a request that we allow

Terminal.Gui/ConsoleDrivers/AnsiResponseParser/AnsiResponseParser.cs

+16-16
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Terminal.Gui;
66

77
internal abstract class AnsiResponseParserBase : IAnsiResponseParser
88
{
9-
private const char Escape = '\x1B';
9+
private const char ESCAPE = '\x1B';
1010
private readonly AnsiMouseParser _mouseParser = new ();
1111
protected readonly AnsiKeyboardParser _keyboardParser = new ();
1212
protected object _lockExpectedResponses = new ();
@@ -74,17 +74,17 @@ protected set
7474
// These all are valid terminators on ansi responses,
7575
// see CSI in https://invisible-island.net/xterm/ctlseqs/ctlseqs.html#h3-Functions-using-CSI-_-ordered-by-the-final-character_s
7676
// No - N or O
77-
protected readonly HashSet<char> _knownTerminators = new (
78-
[
79-
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
80-
81-
// No - N or O
82-
'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
83-
'^', '`', '~',
84-
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
85-
'l', 'm', 'n',
86-
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
87-
]);
77+
protected readonly HashSet<char> _knownTerminators =
78+
[
79+
'@', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
80+
81+
// No - N or O
82+
'P', 'Q', 'R', 'S', 'T', 'W', 'X', 'Z',
83+
'^', '`', '~',
84+
'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i',
85+
'l', 'm', 'n',
86+
'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'
87+
];
8888

8989
protected AnsiResponseParserBase (IHeld heldContent) { _heldContent = heldContent; }
9090

@@ -137,7 +137,7 @@ int inputLength
137137
char currentChar = getCharAtIndex (index);
138138
object currentObj = getObjectAtIndex (index);
139139

140-
bool isEscape = currentChar == Escape;
140+
bool isEscape = currentChar == ESCAPE;
141141

142142
switch (State)
143143
{
@@ -250,7 +250,7 @@ protected void TryLastMinuteSequences ()
250250

251251
// We have something totally unexpected, not a CSI and
252252
// still Esc+<something>. So give last minute swallow chance
253-
if (cur.Length >= 2 && cur [0] == Escape)
253+
if (cur!.Length >= 2 && cur [0] == ESCAPE)
254254
{
255255
// Maybe swallow anyway if user has custom delegate
256256
bool swallow = ShouldSwallowUnexpectedResponse ();
@@ -328,7 +328,7 @@ protected bool ShouldReleaseHeldContent ()
328328

329329
// Finally if it is a valid ansi response but not one we are expect (e.g. its mouse activity)
330330
// then we can release it back to input processing stream
331-
if (_knownTerminators.Contains (cur.Last ()) && cur.StartsWith (EscSeqUtils.CSI))
331+
if (_knownTerminators.Contains (cur!.Last ()) && cur!.StartsWith (EscSeqUtils.CSI))
332332
{
333333
// We have found a terminator so bail
334334
State = AnsiResponseParserState.Normal;
@@ -443,7 +443,7 @@ public bool IsExpecting (string? terminator)
443443
lock (_lockExpectedResponses)
444444
{
445445
// If any of the new terminator matches any existing terminators characters it's a collision so true.
446-
return _expectedResponses.Any (r => r.Terminator.Intersect (terminator).Any ());
446+
return _expectedResponses.Any (r => r.Terminator!.Intersect (terminator!).Any ());
447447
}
448448
}
449449

0 commit comments

Comments
 (0)