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

Prevent division by zero when tab bar width is 0 #191

Merged
merged 2 commits into from
Oct 4, 2023
Merged

Conversation

Adanos020
Copy link
Owner

Fixes #190

Basically, in DockArea::tab_bar_scroll, the scrolling coefficient is determined by a calculation which involves division by the available width. The problem is that when the available width is 0, the division results in infinity which is later multiplied by 0, and that produces a NaN here:

*scroll -= scroll_bar_handle_response.drag_delta().x * points_to_scroll_coefficient;

The scroll coefficient is later used all over the tab bar code, which spreads the NaN like a disease.

My fix for this is basically just turning off all tab bar code when the width is 0.

I also did a bit of clean-up: the Response returned from DockArea::tab_bar is only ever used to obtain the occupied Rect, so I made the function just return the Rect instead.

@Adanos020 Adanos020 merged commit ea88127 into main Oct 4, 2023
4 checks passed
@Adanos020 Adanos020 deleted the fix-side-panels branch October 4, 2023 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tab Title Not Displayed When Surrounded by SidePanels
1 participant