Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ri completion to always return candidates start with a given name #1082

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tompng
Copy link
Member

@tompng tompng commented Jan 12, 2024

Fixes https://bugs.ruby-lang.org/issues/20171

RDoc has a test code like this

assert_equal %w[Foo#Bar  Foo::bar], @driver.complete('Foo.')

Reline doesn't accept this completion list because it does not start from 'Foo.'

To make it work with Reline, completion_proc should always return a list of string that starts with the given completion_target text.

This will also fix this weird behavior in Ruby 3.2 using readline

>> Array.t[TAB]
↓
>> Array
(tab complete deletes text)

@@ -744,7 +744,7 @@ def complete name
complete_klass name, klass, selector, method, completions
complete_method name, klass, selector, completions

completions.sort.uniq
completions.sort.uniq.select {|s| s.start_with? name }
Copy link
Member

Choose a reason for hiding this comment

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

Just a suggestion: maybe call .sort last would be slightly more efficient given the list size being smaller?

@tompng tompng force-pushed the reline_readline_completion_fix branch from df945bc to acaf13d Compare January 21, 2024 16:50
@st0012 st0012 added the bug label Jul 2, 2024
@st0012 st0012 added this to the v6.8.0 milestone Oct 17, 2024
@st0012 st0012 modified the milestones: v6.8.0, v7.0.0 Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

2 participants