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

Inconsistent treatment of backslashes in completion context. #43

Open
maxlandon opened this issue Dec 18, 2023 · 0 comments
Open

Inconsistent treatment of backslashes in completion context. #43

maxlandon opened this issue Dec 18, 2023 · 0 comments
Labels
completions enhancement New feature or request help wanted Extra attention is needed readline

Comments

@maxlandon
Copy link
Member

SUMMARY

Currently this library might suffer from sometimes slightly inconsistent behaviors between the buffer being executed and the one being completed. These inconsistencies are almost invariably due to backslash management. Some of these have been raised in #38.

Here I aim to do a recap so that anyone facing a behavior/bug that is not acceptable to them, might be able to at least burn a couple brain calories on how to fix all of this uniformly. Best case scenario being a code contribution.

State of the buffer before EXECUTION

Currently, the input line buffer is parsed with the github.com/mvdan/sh package, so that the console enables users to include comments in their command lines (saved in history), with those comments stripped before exec:

example [main] > root subcommand --flag value-for-flag \
                 --another-flag file.json # With a comment here, saved in hist but stripped before exec.

The executed line is in effect:

root subcommand --flag value-for-flag --another-flag file.json

The following example will even work in the example app:

example [main] in playground/console/example
> git checkout # This is a comment
  --create testing # And this is another
  --force                                                                                         12:29:42.649

Running git checkout command with branch: testing

State of the buffer before COMPLETION

The parsing code for the line in the completion context is entirely different (copied from this package and slightly modified). This is so that we can take more freedoms on what to pass to the completion context. The added cost however have been until now some inconsistent behavior here and there.

The line splitting code used before sending arguments to the completion engine is here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
completions enhancement New feature or request help wanted Extra attention is needed readline
Projects
None yet
Development

No branches or pull requests

1 participant