fix: clamp widthUntilLineNumberEnd to prevent negative Rect width#301899
Draft
bryanchen-d wants to merge 1 commit intomainfrom
Draft
fix: clamp widthUntilLineNumberEnd to prevent negative Rect width#301899bryanchen-d wants to merge 1 commit intomainfrom
bryanchen-d wants to merge 1 commit intomainfrom
Conversation
When pillRect.width < idealIconAreaWidth (22px) and lineNumbersWidth is 0, the expression pillRect.width - idealIconAreaWidth produces a negative value. Math.min then selects this negative widthUntilLineNumberEnd, which causes pillRect.withWidth(negative) to create a Rect where left > right, throwing 'Invalid arguments: Horizontally offset by N'. Wrap the computation in Math.max(0, ...) so widthUntilLineNumberEnd is clamped to 0 when the pill is too narrow. Fixes #301197
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes a crash in the inline edits gutter indicator layout logic by preventing a negative width from being passed to Rect.withWidth(...) when the pill is narrower than the ideal icon area and line numbers are disabled (width 0).
Changes:
- Clamp
widthUntilLineNumberEndto>= 0whenlayout.lineNumbersWidth === 0to avoid constructing invalidRectinstances.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When pillRect.width < idealIconAreaWidth (22px) and lineNumbersWidth is 0, the expression pillRect.width - idealIconAreaWidth produces a negative value. Math.min then selects this negative widthUntilLineNumberEnd, which causes pillRect.withWidth(negative) to create a Rect where left > right, throwing Invalid arguments: Horizontally offset by N.
Wrap the computation in Math.max(0, ...) so widthUntilLineNumberEnd is clamped to 0 when the pill is too narrow.
Fixes #301197