{{ message }}
fix(client): correct scrollbar width range check - #69839
Open
rajanpanth wants to merge 1 commit into
Open
Conversation
getScrollbarWidth guards the stored Monaco scrollbar width with storedWidth >= 5 || storedWidth <= 25, which is true for every number, so out-of-range values from local storage (e.g. 0 or 100) are applied to the editor instead of the fallback. Use && so only widths in the 5-25 range pass, and add unit tests.
Contributor
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.

Checklist:
mainbranch of freeCodeCamp.What
getScrollbarWidthinclient/src/utils/scrollbar-width.tsis meant to sanitize the persisted Monaco scrollbar width to the 5-25 range, but the guard uses||:Every number is either
>= 5or<= 25, so the condition is a tautology and the fallback is only reachable forundefined/NaN. A corrupted or hand-editedmonacoScrollbarWidthin localStorage (0,100,-3) is applied verbatim to the editor:editor.tsxfeeds this value into Monaco'sverticalScrollbarSize/arrowSizeand a width calculation in four places.The condition wants
&&. One character, plus a unit test file so the range check cannot regress silently again (the bug shipped with the original feature PR #49975 and was never caught because the file had no tests).Verification
scrollbar-width.test.tscovers in-range passthrough, both out-of-range sides, and the unset case, withstoremocked. All 4 pass with the fix. Reverting onlyscrollbar-width.tsfails exactly the two out-of-range tests (expected +0 to be 5,expected 100 to be 5), so the tests isolate the change.Opened directly without an issue per the contributing FAQ guidance for small self-contained fixes; happy to open one if preferred.