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

Pyreadline doesn't properly handle parenthesis #35

Open
Rudedog9d opened this issue May 10, 2018 · 1 comment
Open

Pyreadline doesn't properly handle parenthesis #35

Rudedog9d opened this issue May 10, 2018 · 1 comment

Comments

@Rudedog9d
Copy link
Contributor

Rudedog9d commented May 10, 2018

It looks like pyreadline doesn't properly handle a parenthesis when using readline.get_begidx() and readline.get_endidx(). This manifests when trying to tab complete an option that contain a parenthesis, ex:

# Create a new macro with a paren
macro test(
Beginning macro, use the 'end' command to save.
> echo hello world
> end
# tab complete showing them
macro --show test(<TAB> # all macros will be tab completed

The problem for us is inside shell.py:complete():

            # begidx and endidx are set to the same, 
            # so prefix is set to an empty string and passed to the completer
            begidx = readline.get_begidx()
            endidx = readline.get_endidx()
            line = readline.get_line_buffer()
            prefix = line[begidx:endidx] if line else ''
            line = line[:endidx]
            self.completion_matches = self.get_completions(line, prefix)
@ameily
Copy link
Owner

ameily commented May 10, 2018

Readline splits on special characters, which you can view with:

>>> readline.get_completer_delims()
' \t\n"\\\'`@$><=;|&{('

The open paren character is in the completer delims. So, you can try to just remove the open paren character to see if that fixes the issue.

delims = readline.get_completer_delims().replace('(', '')
readline.set_completer_delims(delims)

I would be reluctant to modify pypsi and would instead advise that you change your shell subclass to set the readline completer delims.

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

No branches or pull requests

2 participants