Skip to content

fix: clear tail tips when setTailTip receives null - #2334

Merged
gnodet merged 1 commit into
jline:masterfrom
PHJ2000:fix-null-tail-tip
Oct 22, 2026
Merged

gnodet merged 1 commit into
jline:masterfrom
PHJ2000:fix-null-tail-tip

Conversation

@PHJ2000

@PHJ2000 PHJ2000 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

setTailTip(null) is documented to clear the tail tip, but enabling TAIL_TIP autosuggestions then entering text throws a NullPointerException in redisplay.

Normalize null to the empty string in the setter. Add a reader regression that clears a previously configured tip and enters a command with tail-tip autosuggestions enabled.

Validation (JDK 25): the regression throws on the unchanged implementation; TERM=xterm mvn -q -pl reader -am verify passes after the fix (883 tests, 2 existing skips, no failures/errors). TERM=xterm avoids the unrelated warning-test failure caused by the local TERM=dumb environment.

Fixes #2332.

Summary by CodeRabbit

  • Bug Fixes
    • Clearing a tail-tip suggestion with null now behaves as expected, allowing the entered command to remain intact.

@coderabbitai

coderabbitai Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f258b0f-59b7-4979-9e91-049ea31fc461
📥 Commits

Reviewing files that changed from the base of the PR and between 72c9a4c and 39912b0.

📒 Files selected for processing: 2
  • reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java
  • reader/src/test/java/org/jline/reader/impl/AutosuggestionTest.java

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

📝 Walkthrough

setTailTip now stores an empty string when passed null. A test checks that, with tail-tip suggestions enabled, clearing the tip still allows the entered command to be returned.

Changes: Tail-tip clearing

Layer / File(s) Summary
Normalize and test cleared tail tips
reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java, reader/src/test/java/org/jline/reader/impl/AutosuggestionTest.java
setTailTip stores an empty string for null. A test clears the tail tip and asserts that entering "command" returns "command".

Priority: ⬇️ Low

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

Change: Bug fix · Severity of issue fixed: Low

Suggested reviewers: gnodet

Merge Risk: ⚪ Minimal · up to 39912

The PR addresses the reported failure and is mergeable with normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: clearing tail tips when setTailTip receives null.
Linked Issues check Passed Issue #2332 requires setTailTip(null) to clear the tail tip and prevent readLine failure with SuggestionType.TAIL_TIP. LineReaderImpl.setTailTip now converts null to "". `AutosuggestionTes…
Out of Scope Changes check Passed The pull request changes only LineReaderImpl.setTailTip and adds its focused regression test. Both changes directly support issue #2332. No unrelated implementation or test changes are present in th…
Full details: Linked Issues check

Explanation

Issue #2332 requires setTailTip(null) to clear the tail tip and prevent readLine failure with SuggestionType.TAIL_TIP. LineReaderImpl.setTailTip now converts null to "". AutosuggestionTest.nullClearsTailTip enables tail-tip autosuggestions, sets and clears a tip, then enters command.

Full details: Out of Scope Changes check

Explanation

The pull request changes only LineReaderImpl.setTailTip and adds its focused regression test. Both changes directly support issue #2332. No unrelated implementation or test changes are present in the reviewed diff.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sonarqubecloud

Copy link
Copy Markdown

@gnodet
gnodet merged commit 60d8ed5 into jline:master Oct 22, 2026
15 checks passed
@gnodet gnodet added the bug label Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setTailTip(null) makes readLine throw an NPE

2 participants