Skip to content

feat: an inlay hint has the padding its language server asks for, on the left or the right - #2210

Closed
lagergren wants to merge 1 commit into
redhat-developer:mainfrom
lagergren:feat/inlay-hint-padding
Closed

lagergren wants to merge 1 commit into
redhat-developer:mainfrom
lagergren:feat/inlay-hint-padding

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Fixes #462

What

LSP4IJ ignored an inlay hint's paddingLeft and paddingRight. A hint sat right against the text next to it, as Qute's tag-parameter hints do (quarkus-ls #968).

Change

LSPInlayHintsProvider.buildWithPadding adds a space before the label for paddingLeft, and after it for paddingRight, for plain and multi-part labels.

  • IntelliJ's declarative inlay API has no margin for one side on 2024.2, 2025.3 or 2026.3: HintMarginPadding is symmetric.
  • The space is a text piece of its own. It isn't clickable, and IntelliJ's cut of a piece to 30 characters never removes it.
  • The hint's format is unchanged, and a hint without padding looks as before.
  • docs/LSPSupport.md mentions the padding.

Not in this PR: VS Code draws a transparent gap outside the hint's background, while ours is a space of the hint's font, inside the background.

Tests

New InlayHintPaddingTest (7 tests): left, right, both, null and false padding; a parameter hint keeps its format; and a multi-part label whose spaces aren't clickable.

  • Red-green: without the change, the 5 padding tests fail and the 2 without padding pass. With it, all 7 pass.
  • Headless on IC 2024.2, 2025.3 and IU 2026.3: 7 of 7 each.
  • The inlay hint tests pass on all three platforms: 19 each.

Behaviour change

Before After
An inlay hint has no padding, whatever its language server asks for It has a space on each side its language server asks for padding; a hint without padding is unchanged

…the left or the right

LSP4IJ ignored the paddingLeft and paddingRight of an inlay hint, so a
hint which its language server asks to keep apart from the text, as the
Qute language server does for the parameters of a user tag
(redhat-developer/quarkus-ls#968), touched it.

The declarative inlay API has no margin for one side: its
HintMarginPadding, the same in 2024.2, 2025.3 and 2026.3, is the same on
both sides. So an inlay hint now has a space before its label when it
asks for paddingLeft, and after it when it asks for paddingRight, as VS
Code leaves a small gap on that side. The space is a text of its own, so
a long label, which IntelliJ shortens to 30 characters, never loses it,
and it is not part of a clickable label part. The format of the hint
does not change, and a hint without padding shows only its label, as
before. Unlike in VS Code, the gap is within the hint's background.

Fixes redhat-developer#462
@lagergren lagergren added this to the 0.30.2 milestone Nov 24, 2026
@lagergren lagergren added the enhancement New feature or request label Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026

Copy link
Copy Markdown

Warning

Review limit reached

This review ran on the open-source allowance, not this organization's plan, because the pull request author doesn't have an assigned seat. Waiting won't change this — ask an organization admin to assign them a seat, or add seats in Billing if every seat is already assigned, then retry.

Next included review available in 23 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 2 included reviews currently available.

Learn how review limits work.

Review configuration:

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: a85f14de-6ac3-4016-bda5-46c66a103412
Commits

Reviewing files that changed from the base of the PR and between d592c89 and 5262323.

Files selected for processing: 3

  • docs/LSPSupport.md
  • src/main/java/com/redhat/devtools/lsp4ij/features/inlayhint/LSPInlayHintsProvider.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/inlayhint/InlayHintPaddingTest.java

@codecov

codecov Bot commented Nov 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 75.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.74%. Comparing base (1b0b053) to head (5262323).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...p4ij/features/inlayhint/LSPInlayHintsProvider.java 75.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2210      +/-   ##
==========================================
+ Coverage   54.59%   54.74%   +0.14%     
==========================================
  Files         834      834              
  Lines       35385    35393       +8     
  Branches     7300     5547    -1753     
==========================================
+ Hits        19320    19376      +56     
+ Misses      13223    13174      -49     
- Partials     2842     2843       +1     

☔ 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

Combined, unchanged, with the other small fixes into #2219, one commit each, so that they take one review instead of six.

@lagergren lagergren closed this Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support for paddingRight in InlayHint

1 participant