question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`NetDriver` key handling is broken on Windows Terminal v1.18+

See original GitHub issue

To repro simply run UI Catalog and press ESC a few times.

image

I found this while trying to track down what I broke in #2612.

I kept going back in my commit history to find where the odd behavior I was seeing didn’t happen. I eventually just tried v2_develop and discovered this was happening. So I tried it on develop too.

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:9

github_iconTop GitHub Comments

3reactions
j4jamescommented, Jul 11, 2023

I don’t know the code base, so this is just a wild guess, but the code here looks suspicious:

https://github.com/gui-cs/Terminal.Gui/blob/db78fe28bce10fe6ae5d4c6062e8b4ef07f7b8fa/Terminal.Gui/ConsoleDrivers/NetDriver.cs#L198-L201

If you get into that branch, cki is going to be set to null, but isEscSeq is not reset to false. So the next time GetConsoleKey is called, if consoleKeyInfo.KeyChar is Esc again, you’re assumedly going to enter that branch with cki now being null. From there you call DecodeEscSeq with null, which in turn calls GetCharArray with null.

At least that’s what it looks like to me.

1reaction
tigcommented, Jul 12, 2023

@BDisp see my latest push to this PR.

There is a bug somewhere that is causing isEscSeq to be true with cki being null. I’ve added a defensive check for this as I’ve not been able to reliably reproduce it in a way that shows me what’s causing it.

Note, I discovered something else that indicates EscSeqUtils may need to be refactored.

If the user presses a key while the terminal is sending an esc sequence (e.g. a '[35` mouse move report), that key info is lost. The result of this is no keystrokes can happen while the user is moving the mouse.

As we move to a world where all drivers rely heavily on emitting and receiving escape sequences, we need EscSeqUtils to be very robust and flexible. It works pretty darn good right now (great job!) but it is fragile and brittle. It doesn’t help that the documentation for ANSI sequences and all the implementations are so sketchy.

I still haven’t figured out what I screwed up in #2612 that has broken netdriver in this regard, FWIW.

Read more comments on GitHub >

github_iconTop Results From Across the Web

WT Preview 1.18 breaks Terminal.Gui keyboard handling ...
Windows Terminal version 1.18.1462.0 Windows build number 10.0.22631.1972 Other Software ... Gui keyboard handling (NetDriver) #15693.
Read more >
Windows Terminal Troubleshooting
This guide addresses some of the common errors and obstacles you may encounter when using Windows Terminal.
Read more >
Windows Terminal Preview 1.18 Release
Welcome back to another Windows Terminal release! This release updates Windows Terminal to version 1.17 and includes all of the features ...
Read more >
Windows Terminal 1.18 Preview Highlights
In this video, Christopher Nguyen (PM on Windows Terminal) and Carlos Zamora (Software Engineer on Windows Terminal) will highlight some ...
Read more >
Tutorial: Enable shell integration in the Windows Terminal
In this tutorial, you learn how to configure your shell to enable shell integration features in the Windows Terminal.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found