Skip to content

Add replacingCurrentWord completion flag and move fuzzy package to readline-api - #383

Merged
stalep merged 1 commit into
aeshell:masterfrom
omatheusmesmo:feat/completion-replace-current-word
Nov 2, 2026
Merged

stalep merged 1 commit into
aeshell:masterfrom
omatheusmesmo:feat/completion-replace-current-word

Conversation

@omatheusmesmo

@omatheusmesmo omatheusmesmo commented Oct 25, 2026 •

Copy link
Copy Markdown
Contributor

Describe Changes

The completion display assumes a candidate always extends the typed word by a shared prefix: a single candidate is appended after the prefix and multiple candidates insert their common prefix. That corrupts the buffer for completion styles where the typed word is not a prefix of the candidates, such as the fuzzy matching planned for aeshell/aesh#510: a typo like comit with candidate commit appends the full name and produces comitcommit.

This adds an opt-in replacingCurrentWord flag to CompleteOperation. When set, a single candidate removes the whole typed word, dashes included, before the full candidate is written, and common-prefix insertion is skipped in favour of listing. The removal uses unix-word-rubout because backward-kill-word treats - as a word delimiter and leaves typed dashes behind. The flag defaults to false, so existing prefix completion behavior is unchanged.

It also moves the org.aesh.readline.fuzzy package from the readline module to readline-api, unchanged in name, so that the aesh completion fallback loads for consumers that exclude the full readline module: jbang, for example, depends on aesh with readline excluded plus readline-api. Nothing outside the package location changes; the fuzzy history search in readline resolves the classes through its readline-api dependency and all its tests keep passing.


@stalep stalep left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, and sorry for the slow turnaround. Two requests before merge — one naming, one build hygiene. I'm fine with the fuzzy package move to readline-api as designed.

  1. Please rename isReplaceCurrentWord(), it doesn't read naturally.
    The interface convention is isX/setX with an adjective-like phrase (isIgnoreOffset, isAppendSeparator, isIgnoreStartsWith), but isReplaceCurrentWord pairs is with an imperative, so the call site reads ungrammatically:
if (!possibleCompletions.get(0).isIgnoreStartsWith()
        && !possibleCompletions.get(0).isReplaceCurrentWord())  // "is replace…?"

My preference is the present participle, which keeps the is/set symmetry and reads as plain English:
- isReplacingCurrentWord() / setReplacingCurrentWord(boolean)
Alternative, if you prefer a noun phrase in the style of isAppendSeparator: isWordReplacement() / setWordReplacement(boolean). Either works for me, just not the imperative under is.
2. Please don't hardcode the JUnit version in readline-api/pom.xml.
The parent pom already defines <junit.version>4.13.2</junit.version> (pom.xml:68) , the new test dependency should use ${junit.version}. (Yes, readline/pom.xml:91 hardcodes the same version; that's pre-existing, but if you're touching this anyway, aligning both lines would be a welcome cleanup, otherwise I'll file a follow-up.)

@stalep

stalep commented Oct 29, 2026

Copy link
Copy Markdown
Member

@omatheusmesmo let me know if you have any questions or disagree with my review

@omatheusmesmo

Copy link
Copy Markdown
Contributor Author

Sorry @stalep , it's been a busy week, but I will get it done by the end of the weekend.

@stalep

stalep commented Oct 30, 2026

Copy link
Copy Markdown
Member

Sorry @stalep , it's been a busy week, but I will get it done by the end of the weekend.

Sure, no rush!

The completion display assumed candidates extend the typed word by a
prefix, which corrupts the buffer for non-prefix candidates such as
fuzzy matches. The flag makes a single candidate replace the whole
word, dashes included, and skips common-prefix insertion when listing.
Also moves the fuzzy package to readline-api, unchanged in name, so
the aesh completion fallback loads for consumers that exclude the
full readline module, like jbang.

* Supports aeshell/aesh#510

Signed-off-by: Matheus Oliveira <matheus.6148@gmail.com>
@omatheusmesmo
omatheusmesmo force-pushed the feat/completion-replace-current-word branch from 4b16ad6 to 618daad Compare October 30, 2026 16:15
@omatheusmesmo omatheusmesmo changed the title Add replaceCurrentWord completion flag and move fuzzy package to readline-api Add replacingCurrentWord completion flag and move fuzzy package to readline-api Oct 30, 2026
@omatheusmesmo

Copy link
Copy Markdown
Contributor Author

Thanks @stalep, both points addressed and pushed:

  • Renamed to isReplacingCurrentWord() / setReplacingCurrentWord(boolean)
  • readline-api/pom.xml now uses ${junit.version}. I aligned readline/pom.xml too, so no follow-up is needed

I'll update aeshell/aesh#695 to the new method name next.

@omatheusmesmo
omatheusmesmo requested a review from stalep October 31, 2026 20:10
@stalep

stalep commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Thanks a lot, merged!

@stalep
stalep merged commit c54ec95 into aeshell:master Nov 2, 2026
19 checks passed
@omatheusmesmo
omatheusmesmo deleted the feat/completion-replace-current-word branch November 2, 2026 10:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants