Skip to content
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

TableView's CollectionNavigator sometimes doesn't work right #3885

Closed
tig opened this issue Dec 10, 2024 · 15 comments · Fixed by #3933
Closed

TableView's CollectionNavigator sometimes doesn't work right #3885

tig opened this issue Dec 10, 2024 · 15 comments · Fixed by #3933
Labels
Milestone

Comments

@tig
Copy link
Collaborator

tig commented Dec 10, 2024

I can't always reproduce this (like right now), but sometimes the Scenario List in UI Catalog doesn't respond to collection navigator keypresses correctly.

When this happens, the category view works fine but the scenario view refuses to coopeate. Pressing b for example goes to some random scenario instead of Bars.

If anyone encounters this while in the debugger please try to debug!

@tig tig added the bug label Dec 10, 2024
@tig tig added this to the V2 Alpha milestone Dec 10, 2024
@tznind
Copy link
Collaborator

tznind commented Jan 25, 2025

Maybe was scroll lock or numlock on? I have not noticed this myself

@tig
Copy link
Collaborator Author

tig commented Feb 25, 2025

I still see this sometimes. Have not been able to consistently repro it.

@tig
Copy link
Collaborator Author

tig commented Feb 26, 2025

I got a repo...

It has to do with this timing related code:

public int GetNextMatchingItem (int currentIndex, char keyStruck)
{
    if (!char.IsControl (keyStruck))
    {
        // maybe user pressed 'd' and now presses 'd' again.
        // a candidate search is things that begin with "dd"
        // but if we find none then we must fallback on cycling
        // d instead and discard the candidate state
        var candidateState = "";

        // is it a second or third (etc) keystroke within a short time
        if (SearchString.Length > 0 && DateTime.Now - _lastKeystroke < TimeSpan.FromMilliseconds (TypingDelay))
        {
            // "dd" is a candidate
            candidateState = SearchString + keyStruck;
        }
        else
        {
            // its a fresh keystroke after some time
            // or its first ever key press
            SearchString = new string (keyStruck, 1);
        }

But setting breakpoints in there "fixes" the problem. Hm....

@tznind
Copy link
Collaborator

tznind commented Feb 27, 2025

Maybe easiest way to handle this is after v2 drivers is merged, we add extensive logging here and when it happens do a retro on the logs.

@tznind
Copy link
Collaborator

tznind commented Feb 27, 2025

I have added lots of trace logging into this class in #3837 , see for example (normal behaviour):

Hopefully this will make it clearer next time it happens

[InputProcessor] [OnKeyDown] InputProcessor raised a
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator began processing 'A', it has been 00:00:00.1265455 since last keystroke
[CollectionNavigatorBase] [GetNextMatchingItem] Appending, search is now for 'DYNA'
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator searching (preferring minimum movement) matched:22
[CollectionNavigatorBase] [GetNextMatchingItem] Found collection item that matched search:22
[MainLoop] [AnySubviewsNeedDrawn] TableView triggered redraw (NeedsDraw=True NeedsLayout=False) 
[AnsiResponseParser] [AppendOutput] AnsiResponseParser releasing 'm'
[InputProcessor] [OnKeyDown] InputProcessor raised m
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator began processing 'M', it has been 00:00:00.1873975 since last keystroke
[CollectionNavigatorBase] [GetNextMatchingItem] Appending, search is now for 'DYNAM'
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator searching (preferring minimum movement) matched:22
[CollectionNavigatorBase] [GetNextMatchingItem] Found collection item that matched search:22
[MainLoop] [AnySubviewsNeedDrawn] TableView triggered redraw (NeedsDraw=True NeedsLayout=False) 
[AnsiResponseParser] [AppendOutput] AnsiResponseParser releasing 'd'
[InputProcessor] [OnKeyDown] InputProcessor raised d
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator began processing 'D', it has been 00:00:01.8252519 since last keystroke
[CollectionNavigatorBase] [GetNextMatchingItem] It has been too long since last key press so beginning new search
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator searching (preferring minimum movement) matched:-1
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator searching (any match) matched:-1
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator found no changes to current index, so clearing search
[CollectionNavigatorBase] [GetNextMatchingItem] CollectionNavigator new SearchString D matched index:23
[MainLoop] [AnySubviewsNeedDrawn] TableView triggered redraw (NeedsDraw=True NeedsLayout=False) 

@BDisp
Copy link
Collaborator

BDisp commented Feb 27, 2025

I really can't repo this 🤷‍♂

@tig
Copy link
Collaborator Author

tig commented Feb 27, 2025

I really can't repo this 🤷‍♂

Try this:

  1. Kill your debug terminal
  2. Start debug on UI Catalog.
  3. IMMEDIATELY click on the Scenario list
  4. QUICKLY press W.

It will not navigate to "Windows and Frameviews"

If you don't do step 1 above, it won't repo.

It's almost 100% repo for me now if I do the above.

@BDisp
Copy link
Collaborator

BDisp commented Feb 27, 2025

How to Kill your debug terminal?

@tig
Copy link
Collaborator Author

tig commented Feb 27, 2025

How to Kill your debug terminal?

Close the Terminal window.

@BDisp
Copy link
Collaborator

BDisp commented Feb 27, 2025

How to Kill your debug terminal?

Close the Terminal window.

But it's already closed. I usually close when exit debugging. But I still can't repo. It's strange. Can you make a gif that show the issue, please?

@tznind
Copy link
Collaborator

tznind commented Feb 27, 2025

@tig if you can repro and can also repro on the v2 drivers branch then the logs should tell us what is going on in the collection navigator. They get generated in the /logs directory (relative to the UICatalog binary)

@tig
Copy link
Collaborator Author

tig commented Feb 27, 2025

  1. Start UICatalog in a fresh Terminal
  2. Move the mouse over Scenarios. Stop.
  3. Click
  4. Press w

It seems related to not moving the mouse. Sometimes it doesn't repro.

Image

@BDisp
Copy link
Collaborator

BDisp commented Feb 27, 2025

Ok I already repo it, but only if I click on the second column (Description). Thus it not found anything that start with "w". That's not an issue, I think.

@BDisp
Copy link
Collaborator

BDisp commented Feb 27, 2025

The only way to achieve what you want is changing the ElementAt method as follow:

    protected override object ElementAt (int idx)
    {
        int col = tableView.FullRowSelect ? 0 : tableView.SelectedColumn;
        object rawValue = tableView.Table [idx, col];

        ColumnStyle style = tableView.Style.GetColumnStyleIfAny (col);

        return style?.RepresentationGetter?.Invoke (rawValue) ?? rawValue;
    }

No matter which column is clicked it's always be considered the first column.

@tig
Copy link
Collaborator Author

tig commented Feb 27, 2025

That's it! I never noticed I was sometimes clicking on the 1st column vs 2nd.

Wanna submit a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

3 participants