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

Tab completion only works for the first command on the line #261

Closed
georgebrock opened this issue Jul 30, 2016 · 2 comments
Closed

Tab completion only works for the first command on the line #261

georgebrock opened this issue Jul 30, 2016 · 2 comments

Comments

@georgebrock
Copy link
Collaborator

It's possible to tab complete the first command on a line, e.g. adtab will complete to add .

It's not possible to complete subsequent commands, e.g. add thing.txt && commtab won't complete to add thing.txt && commit , but it might complete to something else if com matches the name of a file, remote, or branch.

This is because command completion or argument completion is selected based on the naive assumption that if any spaces appear before the thing we're completing, it must be an argument.

@georgebrock
Copy link
Collaborator Author

One solution would be to pass the user's input through Gitsh::Parser to determine exactly what we're completing. We'd have to close unclosed quotes to make sure the input was valid.

This would also give us a good starting point for some more advanced context aware completion (e.g., #25, #80, #220)

georgebrock added a commit that referenced this issue Mar 19, 2017
This is a really major change, and therefore a big diff.

Replaces the Parslet-based parsing expression grammar (PEG) with an
RLTK-based context-free grammar (CFG).

The `Gitsh::Parser` (which converted text into a AST) and
`Gitsh::Transformer` (which converted the AST into useful domain objects)
have been replaced with a `Gitsh::Lexer` (which converts text into tokens)
and `Gitsh::Parser` (which converts tokens into useful domain objects).

Why?
====

Distinguishing between _invalid input_ and _valid but incomplete input_ is
really hard with a PEG. There are various papers on improving PEG error
reporting, and some support in Parslet for various strategies, but I
couldn't find a satisfactory way to accurately work out why parsing failed
without making the grammar significantly more complex.

We want to add support for various multi-line constructs, which means we
need to know if a line is invalid or just waiting for more input. The
specific issues I have in mind are:

- Support multi-line strings
  (#31)

- Add a `:function` command for defining functions
  (#35)

We also want to improve tab-completion in various ways, which also involves
working with very similar types of incomplete input. Most of the
enhancements we have in mind will only be possible if we know more exactly
what we're completing, and re-using some of the parsing code to understand
the input seemed like the most logical approach. Specific issues are:

- Support the same tab completion options as zsh
  (#25)

- Add tab completion for options
  (#80)

- Auto complete stash commands
  (#220)

- Tab completion only works for the first command on the line
  (#261)

Note that this commit doesn't implement any of these enhancements, it just
makes them more likely to happen in the future.

Implementation details
======================

- Introduces equality methods on argument objects, used to testing parser
  output.

- git-prefix correction (i.e. interpreting `git foo` as `foo` when
  `help.autocorrect` is set) has moved from the Parser to the GitCommand
  class.

- The subshell implementation in this commit is not very good. It will be
  significantly improved in the next couple of commits, but it seemed too
  big of a change to roll into this one.
georgebrock added a commit that referenced this issue Apr 1, 2017
This is a really major change, and therefore a big diff.

Replaces the Parslet-based parsing expression grammar (PEG) with an
RLTK-based context-free grammar (CFG).

The `Gitsh::Parser` (which converted text into a AST) and
`Gitsh::Transformer` (which converted the AST into useful domain objects)
have been replaced with a `Gitsh::Lexer` (which converts text into tokens)
and `Gitsh::Parser` (which converts tokens into useful domain objects).

Why?
====

Distinguishing between _invalid input_ and _valid but incomplete input_ is
really hard with a PEG. There are various papers on improving PEG error
reporting, and some support in Parslet for various strategies, but I
couldn't find a satisfactory way to accurately work out why parsing failed
without making the grammar significantly more complex.

We want to add support for various multi-line constructs, which means we
need to know if a line is invalid or just waiting for more input. The
specific issues I have in mind are:

- Support multi-line strings
  (#31)

- Add a `:function` command for defining functions
  (#35)

We also want to improve tab-completion in various ways, which also involves
working with very similar types of incomplete input. Most of the
enhancements we have in mind will only be possible if we know more exactly
what we're completing, and re-using some of the parsing code to understand
the input seemed like the most logical approach. Specific issues are:

- Support the same tab completion options as zsh
  (#25)

- Add tab completion for options
  (#80)

- Auto complete stash commands
  (#220)

- Tab completion only works for the first command on the line
  (#261)

Note that this commit doesn't implement any of these enhancements, it just
makes them more likely to happen in the future.

Implementation details
======================

- Introduces equality methods on argument objects, used to testing parser
  output.

- git-prefix correction (i.e. interpreting `git foo` as `foo` when
  `help.autocorrect` is set) has moved from the Parser to the GitCommand
  class.

- The subshell implementation in this commit is not very good. It will be
  significantly improved in the next couple of commits, but it seemed too
  big of a change to roll into this one.
georgebrock added a commit that referenced this issue Apr 8, 2017
This is a really major change, and therefore a big diff.

Replaces the Parslet-based parsing expression grammar (PEG) with an
RLTK-based context-free grammar (CFG).

The `Gitsh::Parser` (which converted text into a AST) and
`Gitsh::Transformer` (which converted the AST into useful domain objects)
have been replaced with a `Gitsh::Lexer` (which converts text into tokens)
and `Gitsh::Parser` (which converts tokens into useful domain objects).

Why?
====

Distinguishing between _invalid input_ and _valid but incomplete input_ is
really hard with a PEG. There are various papers on improving PEG error
reporting, and some support in Parslet for various strategies, but I
couldn't find a satisfactory way to accurately work out why parsing failed
without making the grammar significantly more complex.

We want to add support for various multi-line constructs, which means we
need to know if a line is invalid or just waiting for more input. The
specific issues I have in mind are:

- Support multi-line strings
  (#31)

- Add a `:function` command for defining functions
  (#35)

We also want to improve tab-completion in various ways, which also involves
working with very similar types of incomplete input. Most of the
enhancements we have in mind will only be possible if we know more exactly
what we're completing, and re-using some of the parsing code to understand
the input seemed like the most logical approach. Specific issues are:

- Support the same tab completion options as zsh
  (#25)

- Add tab completion for options
  (#80)

- Auto complete stash commands
  (#220)

- Tab completion only works for the first command on the line
  (#261)

Note that this commit doesn't implement any of these enhancements, it just
makes them more likely to happen in the future.

Implementation details
======================

- Introduces equality methods on argument objects, used to testing parser
  output.

- git-prefix correction (i.e. interpreting `git foo` as `foo` when
  `help.autocorrect` is set) has moved from the Parser to the GitCommand
  class.

- The subshell implementation in this commit is not very good. It will be
  significantly improved in the next couple of commits, but it seemed too
  big of a change to roll into this one.
georgebrock added a commit that referenced this issue Apr 19, 2017
This is a really major change, and therefore a big diff.

Replaces the Parslet-based parsing expression grammar (PEG) with an
RLTK-based context-free grammar (CFG).

The `Gitsh::Parser` (which converted text into a AST) and
`Gitsh::Transformer` (which converted the AST into useful domain objects)
have been replaced with a `Gitsh::Lexer` (which converts text into tokens)
and `Gitsh::Parser` (which converts tokens into useful domain objects).

Why?
====

Distinguishing between _invalid input_ and _valid but incomplete input_ is
really hard with a PEG. There are various papers on improving PEG error
reporting, and some support in Parslet for various strategies, but I
couldn't find a satisfactory way to accurately work out why parsing failed
without making the grammar significantly more complex.

We want to add support for various multi-line constructs, which means we
need to know if a line is invalid or just waiting for more input. The
specific issues I have in mind are:

- Support multi-line strings
  (#31)

- Add a `:function` command for defining functions
  (#35)

We also want to improve tab-completion in various ways, which also involves
working with very similar types of incomplete input. Most of the
enhancements we have in mind will only be possible if we know more exactly
what we're completing, and re-using some of the parsing code to understand
the input seemed like the most logical approach. Specific issues are:

- Support the same tab completion options as zsh
  (#25)

- Add tab completion for options
  (#80)

- Auto complete stash commands
  (#220)

- Tab completion only works for the first command on the line
  (#261)

Note that this commit doesn't implement any of these enhancements, it just
makes them more likely to happen in the future.

Implementation details
======================

- Introduces equality methods on argument objects, used to testing parser
  output.

- git-prefix correction (i.e. interpreting `git foo` as `foo` when
  `help.autocorrect` is set) has moved from the Parser to the GitCommand
  class.

- The subshell implementation in this commit is not very good. It will be
  significantly improved in the next couple of commits, but it seemed too
  big of a change to roll into this one.
georgebrock added a commit that referenced this issue Apr 19, 2017
This is a really major change, and therefore a big diff.

Replaces the Parslet-based parsing expression grammar (PEG) with an
RLTK-based context-free grammar (CFG).

The `Gitsh::Parser` (which converted text into a AST) and
`Gitsh::Transformer` (which converted the AST into useful domain objects)
have been replaced with a `Gitsh::Lexer` (which converts text into tokens)
and `Gitsh::Parser` (which converts tokens into useful domain objects).

Why?
====

Distinguishing between _invalid input_ and _valid but incomplete input_ is
really hard with a PEG. There are various papers on improving PEG error
reporting, and some support in Parslet for various strategies, but I
couldn't find a satisfactory way to accurately work out why parsing failed
without making the grammar significantly more complex.

We want to add support for various multi-line constructs, which means we
need to know if a line is invalid or just waiting for more input. The
specific issues I have in mind are:

- Support multi-line strings
  (#31)

- Add a `:function` command for defining functions
  (#35)

We also want to improve tab-completion in various ways, which also involves
working with very similar types of incomplete input. Most of the
enhancements we have in mind will only be possible if we know more exactly
what we're completing, and re-using some of the parsing code to understand
the input seemed like the most logical approach. Specific issues are:

- Support the same tab completion options as zsh
  (#25)

- Add tab completion for options
  (#80)

- Auto complete stash commands
  (#220)

- Tab completion only works for the first command on the line
  (#261)

Note that this commit doesn't implement any of these enhancements, it just
makes them more likely to happen in the future.

Implementation details
======================

- Introduces equality methods on argument objects, used to testing parser
  output.

- git-prefix correction (i.e. interpreting `git foo` as `foo` when
  `help.autocorrect` is set) has moved from the Parser to the GitCommand
  class.

- The subshell implementation in this commit is not very good. It will be
  significantly improved in the next couple of commits, but it seemed too
  big of a change to roll into this one.
@georgebrock
Copy link
Collaborator Author

Closing in favour of #296.

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

1 participant