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

Change space addition behaviour while performing tab completions #346

Open
ghost opened this issue Jan 25, 2017 · 3 comments
Open

Change space addition behaviour while performing tab completions #346

ghost opened this issue Jan 25, 2017 · 3 comments

Comments

@ghost
Copy link

ghost commented Jan 25, 2017

Spaces make a great deal of sense when autocompleting in a shell -- they help the user to understand whether the completion occured fully or partially.

However, this does not really make sense for PsySH, at least in certain circumstances. Say, you're trying to do something like:

>>> include_once 'foo.php'

When trying to autocomplete the foo.php file, it inserts a space, and now the user has to remove it and put in the quote for it to work.

I'm not sure whether this behaviour can be even changed, because it seems tab completions are handled by libreadline/libedit. However, I'd like to see PsySH remove the addition of spaces, at least when autocompleting files.

@bobthecow
Copy link
Owner

Autocomplete in PsySH definitely inserts more spaces than it needs to, and I'd love to fix that. But in this case, I'm not able to replicate your exact issue locally...

>>> include_once './foo[tab]

completes to

>>> include_once './foo.php'

… as does the double-quote version of the same.

@ghost
Copy link
Author

ghost commented Feb 18, 2017

The PHP version that ships with Ubuntu uses libedit, and the issue definitely occurs there.

Versions of PHP built on libreadline does not seem to have this issue.

I tried installing the php-readline package, but it doesn't seem to fix it.

@krageon
Copy link
Contributor

krageon commented Aug 30, 2017

Note that readline by default also inserts a space after whatever it autocompletes. There is currently no support for changing rl_completion_append_character which would allow psysh to prevent this from occurring at all. I have an open PR in php-src that fixes this: php/php-src#2720

As for switching your PHP to readline: Assuming you have the extension (readline.so) available, maybe make sure that it is also loaded in your php cli environment. Readline should have precedence over libedit in psysh, so if it is available I don't see why it wouldn't be using that.

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