Fix hover "Loading..." position causing UI jump when description loads#320643
Open
dwidge wants to merge 2 commits into
Open
Fix hover "Loading..." position causing UI jump when description loads#320643dwidge wants to merge 2 commits into
dwidge wants to merge 2 commits into
Conversation
When hovering over a script name in package.json, the 'Loading...' placeholder was shown with ordinal 2000, sorting it after the 'Run Script | Debug Script' buttons (ordinal 1). When the real description arrived from the JSON language server (ordinal 0), it sorted before the buttons, causing a visible jump. Fix by changing the loading message ordinal from 2000 to 0 so it appears in the same position the description will occupy. Fixes microsoft#320604
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts hover item ordering so the “Loading...” placeholder is prioritized ahead of action buttons, and adds a regression test for the reported ordering issue.
Changes:
- Change loading hover ordinal from a large value to
0to ensure it sorts before action items. - Add a regression test that verifies sorting by ordinal places the loading message first.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/vs/editor/contrib/hover/test/browser/contentHover.test.ts | Adds a regression test covering ordinal-based sorting for loading vs action hovers. |
| src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts | Updates the loading hover ordinal to sort earlier than action buttons. |
|
|
||
| public createLoadingMessage(anchor: HoverAnchor): MarkdownHover | null { | ||
| return new MarkdownHover(this, anchor.range, [new MarkdownString().appendText(nls.localize('modesContentHover.loading', "Loading..."))], false, 2000); | ||
| return new MarkdownHover(this, anchor.range, [new MarkdownString().appendText(nls.localize('modesContentHover.loading', "Loading..."))], false, 0); |
Comment on lines
+68
to
+72
| parts.sort(compareBy(hover => hover.ordinal, numberComparator)); | ||
|
|
||
| assert.strictEqual(parts[0], loading, 'Loading (ordinal 0) should sort before buttons (ordinal 1)'); | ||
| assert.strictEqual(parts[1], runScript); | ||
| assert.strictEqual(parts[2], debugScript); |
Author
|
@microsoft-github-policy-service agree |
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.
Problem: When hovering over a script name in
package.json, the "Loading..." placeholder appears below the "Run Script | Debug Script" buttons. When the real description arrives, it sorts above the buttons, causing the buttons to visibly jump down.Root cause:
MarkdownHoverParticipant.createLoadingMessage()hardcodes ordinal2000, sorting the loading message after the buttons (ordinal ~1). The JSON Language Server's description (ordinal ~0) sorts before the buttons, so the content reorders on arrival.Fix: Changed the loading message ordinal from
2000to0so it appears in the same position the description will occupy. The loading message is always replaced atomically when final content arrives, so there's no conflict at ordinal 0.Test: Added a unit test verifying that a loading message (ordinal 0) sorts before action buttons (ordinal 1).
Fixes #320604