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

fix: label "No changes" no more hiding first file of the list #11724

Merged

Conversation

pmiossec
Copy link
Member

@pmiossec pmiossec commented May 7, 2024

when opening "FormLog"
even if it was set as not visible.

Fixes #11679

Reproduce step: double click on a revision in the revision grid

Regression introduced by f8c0353

/!\ Technical reason of the bug:
Previous code was:

        FilterComboBox.Visible = filesPresent || (SearchComboBox.Visible && !string.IsNullOrEmpty(SearchComboBox.Text));
        NoFiles.Visible = !FilterComboBox.Visible;

But as FilterComboBox.Visible is not just a property storing the value directly to a backed field
(it has a complex WinFoms internal logic),
the value retrieved by the getter ( to after set NoFiles.Visible) is sometimes wrong and not the one set to the property :(
The value is not "well" set due to complex internal logic and so a wrong value is used after.

Using a temporary variable fix the issue because the set of the 2 properties has no more impact on each others!

Screenshots

Before

image

After

image

Test methodology

  • Manual

Test environment(s)

  • Git Extensions 33.33.33
  • Build 10b42c5
  • Git 2.45.0.windows.1
  • Microsoft Windows NT 10.0.22631.0
  • .NET 8.0.1
  • DPI 96dpi (no scaling)
  • Portable: False
  • Microsoft.WindowsDesktop.App Versions
    Microsoft.WindowsDesktop.App 6.0.26 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 7.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
    Microsoft.WindowsDesktop.App 8.0.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@@ -1070,6 +1070,7 @@ private void FileStatusListLoading()
FileStatusListView.Groups.Clear();
FileStatusListView.Items.Clear();
FileStatusListView.EndUpdate();
FileStatusListView.BringToFront();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather set the visibility in dependency on whether the commit is empty (tested with branch mstv/repro/empty_commit).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set visibility is preferred, bring to front disrupts but just changing Visible seem to change order in some situations at least.
I had some problems here...
Whatever that works is OK for me.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have a look again but the problem is that visibility is already set to false and the label is still visible 🤷

So I tried that as we already play with that to bring the label to front.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we push the lable to the back rather change the z-order of other controls?

@pmiossec pmiossec force-pushed the fix_no_changes_hidding_label branch from 10b42c5 to f171308 Compare May 15, 2024 08:54
@pmiossec pmiossec force-pushed the fix_no_changes_hidding_label branch from f171308 to 7e210b8 Compare May 15, 2024 10:41
@pmiossec
Copy link
Member Author

I have spent some time investigating and found the real reason behind the regression in SetFileStatusListVisibility() (introduced by f8c0353 ).

It was a difficult investigation partly because I didn't know the search feature.

Explained in the commit message (that I reproduce here):

Previous code was:

       FilterComboBox.Visible = filesPresent || (SearchComboBox.Visible && !string.IsNullOrEmpty(SearchComboBox.Text));
       NoFiles.Visible = !FilterComboBox.Visible;

But as FilterComboBox.Visible is not just a property storing the value directly to a backed field
(it has a complex WinFoms internal logic),
the value retrieved by the getter ( to after set NoFiles.Visible) is sometimes wrong and not the one set to the property :(
The value is not "well" set due to complex internal logic and so a wrong value is used after.

Using a temporary variable fix the issue because the set of the 2 properties has no more impact on each others!

@pmiossec
Copy link
Member Author

Investigation was painful and time consuming (also partly because, as I said I didn't know the search feature and the bug let me think that I missed something logical) and make me doubt about my knowledge of the De Morgan's Law Formula !(A||B) = !A && !B because it seems the 2 parts were not returning the same value 🤯

but in fact the "bad behavior" lie in FilterComboBox.Visible getter/setter implementation/behavior....: we don't always get back the value that have just been set 😕

Copy link
Member

@mstv mstv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Investigation was painful and time consuming
We don't always get back the value that have just been set

Heavy! Good to know!

// Use variable to prevent bad value retrieved from `Visible` property
bool filesToFilter = filesPresent || (SearchComboBox.Visible && !string.IsNullOrEmpty(SearchComboBox.Text));
FilterComboBox.Visible = filesToFilter;
NoFiles.Visible = !filesToFilter;
if (NoFiles.Visible)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❔ Then also

Suggested change
if (NoFiles.Visible)
if (!filesToFilter)

Or is only ComboBox affected?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or is only ComboBox affected?

It seems to be OK for the label but as I can't be sure, you're right it's better to be careful. Done.

Copy link
Member

@gerhardol gerhardol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

approved pending mstv comment

I spent a lot of time on this too, handled many cases but missed this...
Thanks

when opening "FormLog"
even if it was set as not visible.

Fixes gitextensions#11679

Reproduce step: double click on a revision in the revision grid

Regression introduced by f8c0353

/!\ Technical reason of the bug:
Previous code was:

            FilterComboBox.Visible = filesPresent || (SearchComboBox.Visible && !string.IsNullOrEmpty(SearchComboBox.Text));
            NoFiles.Visible = !FilterComboBox.Visible;

But as `FilterComboBox.Visible` is not just a property storing the value directly to a backed field
(it has a complex WinFoms internal logic),
 the value retrieved by the getter ( to after set `NoFiles.Visible`) is sometimes wrong and not the one set to the property :(
The value is not "well" set due to complex internal logic and so a wrong value is used after.

Using a temporary variable fix the issue because the set of the 2 properties has no more impact on each others!
@pmiossec pmiossec force-pushed the fix_no_changes_hidding_label branch from 7e210b8 to 19062b8 Compare May 16, 2024 08:03
@pmiossec pmiossec merged commit fce1fd0 into gitextensions:master May 16, 2024
4 checks passed
@pmiossec pmiossec deleted the fix_no_changes_hidding_label branch May 16, 2024 20:59
@RussKie
Copy link
Member

RussKie commented May 17, 2024

Investigation was painful and time consuming (also partly because, as I said I didn't know the search feature and the bug let me think that I missed something logical) and make me doubt about my knowledge of the De Morgan's Law Formula !(A||B) = !A && !B because it seems the 2 parts were not returning the same value 🤯

but in fact the "bad behavior" lie in FilterComboBox.Visible getter/setter implementation/behavior....: we don't always get back the value that have just been set 😕

Ah yes, Control.Visible (and few other properties) have complex logic behind them, and one shouldn't rely on those directly for state keeping purposes.

@RussKie RussKie added this to the vNext milestone May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

First file path is hidden by "No changes" in commit details form
4 participants