Skip to content

Fix hover "Loading..." position causing UI jump when description loads#320643

Open
dwidge wants to merge 2 commits into
microsoft:mainfrom
dwidge:fix/320604-hover-loading-ordinal
Open

Fix hover "Loading..." position causing UI jump when description loads#320643
dwidge wants to merge 2 commits into
microsoft:mainfrom
dwidge:fix/320604-hover-loading-ordinal

Conversation

@dwidge

@dwidge dwidge commented Jun 9, 2026

Copy link
Copy Markdown

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 ordinal 2000, 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 2000 to 0 so 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

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
Copilot AI review requested due to automatic review settings June 9, 2026 18:11

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 0 to 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);
@dwidge

dwidge commented Jun 9, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Package json viewer shows Loading... under the 2 Run Script, Debug Script buttons but the descriptions are shown above

3 participants