Refactor stickyScrollWidget.ts for improved code quality and readability #252332
+156
−65
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.
This PR refactors the
stickyScrollWidget.ts
file to improve code quality, readability, and maintainability without changing any functionality or behavior.Key Improvements
🔧 Constants Extraction
FOLDING_ICON_WIDTH
(26px)Z_INDEX_LAST_LINE
andZ_INDEX_REGULAR_LINE
for z-index valuesFOLDING_OPACITY_TRANSITION_DURATION
(0.5s)STICKY_WIDGET_ID
for widget identifierSTICKY_LINE_CONTENT_CLASS
, etc.)📦 Method Decomposition
Broke down large, complex methods into focused, single-responsibility helpers:
_renderRootNode
→ smaller methods:_processExistingLines
- handles existing sticky line updates_renderNewLines
- renders new sticky lines from scratch_finalizeStickyLines
- finalizes widget state and layout_renderChildNode
→ smaller methods:_getActualInlineDecorations
- safely extracts inline decorations_renderLineContent
- handles line content rendering_createLineElement
- creates line DOM elements_createLineNumberElement
- creates line number DOM elements🛠️ Utility Methods Added
_shouldSkipStateUpdate
- simplifies complex boolean logic insetState
_setElementPosition
- consolidates position styling patterns_setLineHeightAndHeight
- consolidates height styling patterns_isValidLineIndex
- provides consistent range checking✨ Code Quality Enhancements
Before/After Example
Before:
After:
All changes preserve existing functionality and public interfaces while significantly improving code readability and maintainability. The refactoring follows VS Code's coding guidelines including proper indentation, naming conventions, and JSDoc style comments.
Fixes #252331.
Warning
Firewall rules blocked me from connecting to one or more addresses
I tried to connect to the following addresses, but was blocked by firewall rules:
electronjs.org
node-gyp
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.