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

Support short class name for class auto-completion #292

Closed
theofidry opened this issue Mar 12, 2016 · 2 comments
Closed

Support short class name for class auto-completion #292

theofidry opened this issue Mar 12, 2016 · 2 comments

Comments

@theofidry
Copy link
Contributor

When using the default PsySH shell (v0.7), if I try the tab auto-completion when having typed "R", I will get:

  • RuntimeException
  • RangeException
  • RecursiveIteratorIterator

But if I have a service Dummy/Run, it won't appear... I guess it's because the classname matcher doesn't account for the class short names. It would be great if their could be a support for it!

Cheers

@theofidry
Copy link
Contributor Author

I naively tried to change https://github.com/bobthecow/psysh/blob/master/src/Psy/TabCompletion/Matcher/ClassNamesMatcher.php#L45 for including short class names as well:

array_filter(
                get_declared_classes(),
                function ($className) use ($quotedClass) {
                    $shortClassName = substr($className, strrpos($className, '\\') + 1);

                    $classNameMatch = AbstractMatcher::startsWith($quotedClass, $className);
                    $shortClassNameMatch = AbstractMatcher::startsWith($quotedClass, $shortClassName);

                    return $classNameMatch || $shortClassNameMatch;
                }
            )

But somehow psysh just becomes unresponsive after that :/

@bobthecow
Copy link
Owner

Unfortunately this isn't possible, due to limitations in readline. It strips out completions that don't match the current input, so even if we provide Dummy\Run as a completion for Ru, readline would refuse to show it :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants