From fbb3c045b1925d15906c88dc7267860945186305 Mon Sep 17 00:00:00 2001 From: dwidge Date: Tue, 9 Jun 2026 20:07:19 +0200 Subject: [PATCH 1/2] Fix hover 'Loading...' position causing UI jump when description loads 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 #320604 --- .../hover/browser/markdownHoverParticipant.ts | 2 +- .../hover/test/browser/contentHover.test.ts | 20 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts b/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts index 9cd72e14497e45..85543d1b3a210b 100644 --- a/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts +++ b/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts @@ -94,7 +94,7 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant { ); }); }); + + test('issue #320604: Loading message ordinal 0 sorts above action buttons at ordinal 1', () => { + const anchor = new Range(1, 1, 1, 10); + const owner = {}; + + const loading = new MarkdownHover(owner, anchor, [new MarkdownString().appendText('Loading...')], false, 0); + const runScript = new MarkdownHover(owner, anchor, [new MarkdownString().appendText('Run Script')], false, 1); + const debugScript = new MarkdownHover(owner, anchor, [new MarkdownString().appendText('Debug Script')], false, 1); + + // Parts arrive with buttons before loading (simulating fast npm provider, slow description) + const parts = [runScript, debugScript, loading]; + 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); + }); }); From bd1a6660bf860222bc53d17b8ff8413d1e57fea2 Mon Sep 17 00:00:00 2001 From: dwidge Date: Tue, 9 Jun 2026 20:16:10 +0200 Subject: [PATCH 2/2] Address Copilot review: fix non-deterministic test, add rationale comment --- .../contrib/hover/browser/markdownHoverParticipant.ts | 3 +++ .../editor/contrib/hover/test/browser/contentHover.test.ts | 7 +++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts b/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts index 85543d1b3a210b..1fc0761bfb2724 100644 --- a/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts +++ b/src/vs/editor/contrib/hover/browser/markdownHoverParticipant.ts @@ -94,6 +94,9 @@ export class MarkdownHoverParticipant implements IEditorHoverParticipant { 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); + // Both buttons have ordinal 1; only assert they appear after loading + assert.strictEqual(parts.length, 3); + assert.ok(parts[1] === runScript || parts[1] === debugScript); + assert.ok(parts[2] === runScript || parts[2] === debugScript); + assert.notStrictEqual(parts[1], parts[2]); }); });