-
Notifications
You must be signed in to change notification settings - Fork 64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OCGV: Sometimes exits as soon as arrow key is pressed #167
Comments
I've tried dozens of times and I can't get this to repro. Can you still repro it with what's in Note that because of #93 the initial behaviour is different than when you first reported this and it might be masking the issue? |
Ive just cloned master and built the module, I can still trigger this, Not sure if its relevant but im using a mac. Ive triggered it by doing the following This is not whats triggered it in larger scripts this was a part of however this does seem to somewhat reliably produce the bug. Hope this helps, If i can be of anymore assistance please do let me know |
I cannot repro this on Debian in WSL or Windows. I do not have access to a Mac.
Is this how you repo it? |
Thats correct, after 3, if you try to scroll down to select an item in OCGV it should skip |
Just managed to trigger this on WSL in Windows Terminal from master
steps to repro Paste in the code, hit ESC 3 or 4 time rapidly during run 0, you should then find when the next OCGV pop ups, try using arrow keys to move down the list. It should skip and go to the next run without letting you select anything. |
Got it. Repo'd on Debian. But not Windows. I have no ideas on what the cause could be. The stack trace you posted points to something involving PowerShell:
How did you collect that stack trace? |
Glad you managed to reproduce it! The stack was from |
I tested on Ubuntu (WSL) and I can reproduce the error, but without open the warning window. By symptoms, it seems that the OCGV is not calling |
@BDisp Do you think this is related? I don't see it. Should it be a separate issue? |
Odd that you're not seeing ...
// Run the GUI.
Application.Run();
Application.Shutdown();
// Called when ESC is pressed:
private void Close()
{
_cancelled = true;
Application.RequestStop();
} |
I tested with the above code provided. Should that code explicit call Application.Shutdown? Since the OCGV already call, sorry my mistake. |
That code is the code in OCGV; I pasted it to show why I think OCGV is actually calling Shutdown. |
Sorry, I meaning if this code should call |
No, OCGV is a PowerShell Cmdlet that calls I just instrumented OCGV and using this version of the script, it's clear Shutdown is being called. So that's not the cause of this issue. Write-Host "start of script"
$list=@(1..100)
$count =0
do{
$list | Out-consoleGridView -Verbose -OutputMode Single -Title $count
#$platform.name.split()
Write-Host "ocgv exited"
$count ++
}
while ($count -lt 3)
Write-Host "end of script"
|
@Tigger2014 - did this issue ever reproduce for you when the ESC key was not involved? Do you have repro that involves ONLY the arrow key causing the cmdlet to exit? |
I've seen it happen when i think the esc key wasn't involved but it's not code i can share unfortunately. Im also not 100% sure ESC wasn't touched. |
Ok, I'll keep poking around. My current suspicion is that @BDisp was on the right track and this has something to do with the way the Terminal.Gui So, if you figure out how to repro it WITHOUT involving the ESC key please yell! |
The other potential culprit is the "hack" in OCGV that resets the "Application Cursor" by emitting an ANSI ESC sequence when it closes: The thought (which may be way off base) is that this ESC sequence is getting echo'd back and causing OCGV to think the user pressed the ESC key. |
@tig see the |
Thinking better I bet that this is really the culprit, because the |
Just commented out that line, Still happens unfortunately |
Further to this, not sure it helps much but swapping Seems this could be related to your suggestion
|
For sure that is. Unfortunately, that interval delay is necessary to unix process all the Ansi Esc Sequence. If no more char exist after the delay then assumes that only the Esc key was pressed and process it alone, otherwise continuous reading all chars to get a key combination, like Alt, Ctrl-Alt or a mouse event, whatever. Maybe lowing down the delay to check if it work without affect his functionality. |
Found these docs (see below) on the feature I think you are talking about @BDisp. Looks like you can change the setting at runtime with an Environment Variable e.g.
Set time taken to release an Escape keystroke to 1ms I tested setting it to 2000 and saw Esc being delayed so it seems to work. Although from the docs docs it sounds like the same setting interacts with mouse events:
|
I submitted the pr gui-cs/Terminal.Gui#1970 which I think fixes the ESC delay issue. I also think that the title of this issue isn't really an issue. What happen when the OCGV exits on a arrow key press is because there was a pending ESC key pressed to be processed and pressing the arrow key will awake the ESC, processing it first causing the app exit. So, the main problem here is the ESC delay issue on the CursesDriver which affect Linux and Mac OS. |
@BDisp If you happen to have a build of the module with your changes happy to test and see if it does indeed fix this issue. |
I only have this branch https://github.com/BDisp/GraphicalTools/tree/solution-with-gui-project, where I added the Terminal.Gui project with the "cursesdriver-esc-delay-fix" branch, instead of the nuget package. You must have the clone of the Terminal.Gui with the pr gui-cs/Terminal.Gui#1970 and build. |
Yep did that and can confirm this fixes it |
This issue is fixed in Terminal.Gui v1.8+. PR #184 will close it. |
Prerequisites
Steps to reproduce
This one seems a bit random but ive managed to isolate it a block of code i think can trigger it sometimes. It might take a good few runs of the below code to get it to happen.
I know the split will error on this by design as it seems to help trigger this more often.
What should happen is when running this loop with F8 in VS code sometime the first iteration will skip when you try to arrow down to select one in the list.
Version used is master compiled from source but same exact thing happens with 0.6.2
Expected behavior
OCGV not to skip
Actual behavior
occasionally OCGV exits without allowing you to select anything
Error details
Environment data
Version
0.6.3
Visuals
The text was updated successfully, but these errors were encountered: