Skip to content

fix: show the hovers of several language servers in the order of their names - #2058

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/sort-hovers-by-language-server
Nov 21, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:fix/sort-hovers-by-language-server

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #390.

A hover asks each language server of the file, and showed their answers in the order of the list of language servers that LanguageServiceAccessor.getLanguageServers gives for the file. That list is filled as each language server has started and has the file, from chains that run in parallel, so its order changes from one hover to the next, even with both language servers running. So the same hover showed the answers of two language servers in a different order each time, as #390 describes.

The answers now come in the order of the display names of the language servers, regardless of case, then of their ids, as agreed in #390 (LSPHoverSupport).

Not here: the empty first page of #390, the hover of a language server which answers without contents. Since 71f6d73, such a hover gives no documentation target, so it no longer shows as a page.

Test: HoverOrderTest asks for the hover of two language servers while one of them is still starting, which makes it come last in the list: the answer of the one whose name comes first comes first, whichever starts last, and names are compared regardless of case. Without the change, the test where the first-named one starts last and the case test fail on each run, with the answers in the order Zeta, Alpha. It and the documentation and hover tests pass (36 tests).

…r names

A hover asks each language server of the file and shows their answers in
the order in which the language servers were found for the file, which
is the order in which each one was started and had the file: it changes
from one hover to the next, so the same hover showed the answers of two
language servers in a different order each time. The answers now come in
the order of the names of the language servers, regardless of case, then
of their ids.
@lagergren lagergren added this to the 0.30.2 milestone Nov 21, 2026
@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Hover information from multiple language servers is now presented in a consistent order, sorted alphabetically by server name without regard to capitalization. When servers have matching names, their results follow a stable secondary order. This replaces the previous ordering, which could vary depending on how servers were discovered.

Hover requests now follow a deterministic order based on case-insensitive language-server display names, with server IDs as a tie-breaker. Tests check the order when server discovery order changes and when names differ only by case.

Changes: Hover ordering

Layer / File(s) Summary
Sort hover requests and verify result order
src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPHoverSupport.java, src/test/java/com/redhat/devtools/lsp4ij/features/documentation/HoverOrderTest.java
Eligible language servers are sorted by display name without case sensitivity, then by ID, before hover requests are collected. Tests check result order across reversed discovery sequences and case differences in server names.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: angelozerr

Merge Risk: Minimal · up to fecc3

Hovers from several language servers now appear in a stable order by server name. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title states the main change: hovers from several language servers are shown in the order of their names. The raw summary confirms that LSPHoverSupport now sorts eligible servers by case-insensiti…
Description check Passed The description explains the cause (server order depends on parallel startup), the fix (sort by display name ignoring case, then by ID), the excluded items from #390, and the new HoverOrderTest. It ma…
Linked Issues check Passed [#390] The directly linked issue asks for a deterministic hover order for several language servers while the same servers run. Alphabetical order by server name is named as one acceptable approach. At…
Out of Scope Changes check Passed The change set, as summarized for the whole PR against merge base b982bd4, touches LSPHoverSupport.java (the sort comparator and its use before hover requests) and adds HoverOrderTest.java. Both dire…
Full details: Title check

Explanation

The title states the main change: hovers from several language servers are shown in the order of their names. The raw summary confirms that LSPHoverSupport now sorts eligible servers by case-insensitive display name, then by ID, and the test covers that ordering.

Full details: Description check

Explanation

The description explains the cause (server order depends on parallel startup), the fix (sort by display name ignoring case, then by ID), the excluded items from #390, and the new HoverOrderTest. It matches the changeset.

Full details: Linked Issues check

Explanation

[#390] The directly linked issue asks for a deterministic hover order for several language servers while the same servers run. Alphabetical order by server name is named as one acceptable approach. At head, LSPHoverSupport.getHover(...) sorts the language servers with BY_SERVER_NAME (display name, String.CASE_INSENSITIVE_ORDER, then server id) before it creates the hover futures. mergeInOneFuture keeps that list order. The order therefore no longer depends on discovery order. HoverOrderTest holds one server's initialize while the other opens the file. It checks that the server with the first name comes first whichever server starts last, and that name comparison ignores case. The empty first page in #390 is a symptom. The PR excludes it and states that a hover with empty contents gives no documentation target since 71f6d73. That claim was not verified in this review. The ordering requirement, which is the main objective, is met by code at head. The author reports 36 passing tests. Those results were not re-run here.

Full details: Out of Scope Changes check

Explanation

The change set, as summarized for the whole PR against merge base b982bd4, touches LSPHoverSupport.java (the sort comparator and its use before hover requests) and adds HoverOrderTest.java. Both directly serve the #390 ordering objective. No unrelated file or behavior change was identified. The file-level diff tool was unavailable, so the summary of changed files was used. The head contents of LSPHoverSupport.java were read and match the summary.

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 91a1a825-1e3d-46bb-b104-42db99d8c540
Commits

Reviewing files that changed from the base of the PR and between b982bd4 and fecc310.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/features/documentation/LSPHoverSupport.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/documentation/HoverOrderTest.java

Included review availability: This review used your included allowance. Your plan provides up to 2 included reviews per hour; 0 remain after this review.

@codecov

codecov Bot commented Nov 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.50%. Comparing base (b982bd4) to head (fecc310).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2058      +/-   ##
==========================================
+ Coverage   49.49%   49.50%   +0.01%     
==========================================
  Files         813      813              
  Lines       33350    33354       +4     
  Branches     5195     5195              
==========================================
+ Hits        16505    16512       +7     
+ Misses      14272    14269       -3     
  Partials     2573     2573              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@lagergren
lagergren merged commit c409a90 into redhat-developer:main Nov 21, 2026
9 checks passed
@lagergren lagergren added bug Something isn't working hover labels Nov 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working hover

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Organize hover responses in a predictable way for ease of use

1 participant