Skip to content

test: the label test of a completion list's default edit range fails without the label fallback - #2275

Merged
lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/completion-default-edit-range-label
Nov 26, 2026
Merged

lagergren merged 1 commit into
redhat-developer:mainfrom
lagergren:test/completion-default-edit-range-label

Conversation

@lagergren

Copy link
Copy Markdown
Collaborator

Follow-up to #2268, as its review said.

What

The test of the label fallback that #2268 added, testAnItemWithOnlyALabelReplacesTheDefaultEditRangeWithItsLabel, passed without #2268's fix too. LSP4IJ inserts the label of an item without a text edit in place of the word before the caret, and in that test the word before the caret was the whole document (ga became gap-1 either way).

Change

  • The label test: its default edit range now covers ga-tail, more than the word before the caret.
    • With the fallback, the label replaces the whole range: gap-1.
    • Without it, only the word is replaced: gap-1-tail.
  • Both lists: their edit ranges stay within the document. They ended at character 6 or 8 of a 2-character line.
  • Indentation: one line of fix: fall back to getLabel() when textEditText is missing, per LSP 3.17 #2268 gets its indentation back.

Tests

…without the label fallback

The test of redhat-developer#2268 passed without its fix too, since LSP4IJ inserts the label of an item without a text edit in place of the word before the caret, which was the whole text. Its default edit range now covers "ga-tail", more than that word, so the fallback gives "gap-1" and the word insertion "gap-1-tail". The edit ranges of both lists stay within the document, and an indentation of redhat-developer#2268 is restored.
@lagergren lagergren added this to the 0.30.2 milestone Nov 26, 2026
@coderabbitai

coderabbitai Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Tests
    • Updated completion test coverage to verify that an item-specific text edit is applied when a default edit range is also present.
    • Adjusted the test scenario to check the resulting text replacement.
  • User impact
    • No user-visible behavior changes are included in this update.

The completion test now uses updated default and item-specific edit ranges and places the caret between ga and -tail. The supplied production-code hunk is unchanged.

Changes: Completion edit-range test

Layer / File(s) Summary
Update completion fixture
src/test/java/com/redhat/devtools/lsp4ij/features/completion/CompletionItemDefaultsEditRangeTest.java
The test comments and range values now describe the updated fixtures. The caret is between ga and -tail. The test still checks the item-specific text edit result.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Other

Suggested reviewers: chiragnarasimha, angelozerr

Merge Risk: Minimal · up to 0d68d

This change only adjusts a test so it distinguishes the label fallback from ordinary word replacement. Production behavior is unchanged, so merge risk is minimal.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a test for the label fallback of a completion list's default edit range, and its failure without the fallback. The changeset updates that test (default edit range now …
Description check Passed The description explains the follow-up to #2268, why the label test passed without the fix, what the test now covers, and how the change was verified. It matches the changeset.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a test for the label fallback of a completion list's default edit range, and its failure without the fallback. The changeset updates that test (default edit range now covers ga-tail) and adjusts the related fixtures, so the title matches the primary change.

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: 6acec852-91e8-4e42-adce-5b27bed4d4fd
Commits

Reviewing files that changed from the base of the PR and between 01b5528 and 0d68d99.

Files selected for processing: 2

  • src/main/java/com/redhat/devtools/lsp4ij/features/completion/LSPCompletionContributor.java
  • src/test/java/com/redhat/devtools/lsp4ij/features/completion/CompletionItemDefaultsEditRangeTest.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 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.10%. Comparing base (01b5528) to head (0d68d99).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2275      +/-   ##
==========================================
+ Coverage   58.07%   58.10%   +0.02%     
==========================================
  Files         848      848              
  Lines       36436    36436              
  Branches     5717     7541    +1824     
==========================================
+ Hits        21162    21170       +8     
+ Misses      12283    12277       -6     
+ Partials     2991     2989       -2     

☔ 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
lagergren merged commit 079e459 into redhat-developer:main Nov 26, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant