Fuzzy find completion candidates

22 views
Skip to first unread message

Max Schluter

unread,
May 14, 2019, 11:18:32 AM5/14/19
to jline-users
Hi there,

I was wondering if there is any way to make the LineReader do a fuzzy find under all the completion candidates instead of displaying all of them? And is it possible to change the tab completion output to a list, instead of being displayed in a grid?

Cheers,

Max

Guillaume Nodet

unread,
May 14, 2019, 12:06:58 PM5/14/19
to jline...@googlegroups.com
On the fuzzy completer, there is currently some logic to fix typo, which does compute the difference between the buffer and candidates.  The maximum number of "errors" is 2, but it can be raised.  But this only works on the full word, so it may need to be enhanced to work on the beginning of the word only.

A single list instead of a grid is currently not supported, but I see a few ways to make it work:
  * the first one should not require any code change, you just need to make sure your completion items have a very long description though you may end up with weird parentheses, so that would be a bit ugly
  * the second one would be to allow customizing the few hard coded constants that control the grid appearance: https://github.com/jline/jline3/blob/master/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java#L4841-L4844 . I think changing the MARGIN_BETWEEN_COLUMNS to a value greater or equal to the screen width should force a single column
  * the best way would be to combine the above and slightly alter the code to add a new variable that would be the maximum number of columns, the number of columns is computed here: https://github.com/jline/jline3/blob/master/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java#L4898-L4905

Cheers,
Guillaume Nodet

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline-users...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jline-users/c4b17ead-b631-4741-819c-0fac53d775e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Max Schluter

unread,
May 14, 2019, 4:46:48 PM5/14/19
to jline-users
Thanks Guillaume! 

I will try your suggestions to make the them display as a list. Essentially, what I'm looking for is something like fzf (https://github.com/junegunn/fzf), which filters the list of candidates based on some similarity score to the buffer. To this end, is it possible to only show the top 10 candidates that are the most similar to the current buffer?


On Tuesday, 14 May 2019 18:06:58 UTC+2, gnodet wrote:
On the fuzzy completer, there is currently some logic to fix typo, which does compute the difference between the buffer and candidates.  The maximum number of "errors" is 2, but it can be raised.  But this only works on the full word, so it may need to be enhanced to work on the beginning of the word only.

A single list instead of a grid is currently not supported, but I see a few ways to make it work:
  * the first one should not require any code change, you just need to make sure your completion items have a very long description though you may end up with weird parentheses, so that would be a bit ugly
  * the second one would be to allow customizing the few hard coded constants that control the grid appearance: https://github.com/jline/jline3/blob/master/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java#L4841-L4844 . I think changing the MARGIN_BETWEEN_COLUMNS to a value greater or equal to the screen width should force a single column
  * the best way would be to combine the above and slightly alter the code to add a new variable that would be the maximum number of columns, the number of columns is computed here: https://github.com/jline/jline3/blob/master/reader/src/main/java/org/jline/reader/impl/LineReaderImpl.java#L4898-L4905

Cheers,
Guillaume Nodet

On Tue, May 14, 2019 at 5:18 PM Max Schluter <maxsch...@gmail.com> wrote:
Hi there,

I was wondering if there is any way to make the LineReader do a fuzzy find under all the completion candidates instead of displaying all of them? And is it possible to change the tab completion output to a list, instead of being displayed in a grid?

Cheers,

Max

--
You received this message because you are subscribed to the Google Groups "jline-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jline...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages