mutable `Helper` in functions
See https://github.com/gwenn/rustyline/pull/4
And I add a new example/bracket_parser.rs to demo Parser trait.
btw, rightnow I have no idea how to represent change: InputEdit.
Thank you for all your proposals. But please only one feature at a time: either mut Helper or Parser but not both in the same PR.
See https://github.com/kkawakam/rustyline/blob/ceafb7f8057974201d0e76ac9fc7aaac3998a048/src/undo.rs#L9 for a possible InputEdit impl (except for Begin / End)
But please only one feature at a time: either mut Helper or Parser but not both in the same PR.
Understand, and since the Parser::parse requires &mut self, I think I can firstly fix all issue (like create ValidationContext from State) for mut Helper. Merge it firstly.
And then create another PR for Parser (as well as InputEdit)
Here is the update under your suggestions.
I think the Invoke should impl for LineBuffer and String, rather than State and &str.
The &str could be replaced to String since itself will be changed in invoke.
And State could be replaced to LineBuffer since Invoke seems only require LineBuffer.
How do you think that?
I haven't fixed fn invoke(&mut self, cmd: Cmd) in this commit, I will try to implement this feature in future.
You need the State to invoke a Cmd on a LineBuffer for Undo / Kill ring.
Like Changeset here:
https://github.com/kkawakam/rustyline/blob/ceafb7f8057974201d0e76ac9fc7aaac3998a048/src/completion.rs#L102-L105
Or at least use a part of State to create a ValidationContext? Since here we already make a mutable reference from State.helper, then it's difficult to have another mutable refence from entire State (will be ValidationContext::new(self) in code).
https://github.com/kkawakam/rustyline/blob/8fc00376936939a948014eadd878b8a8898c375e/src/edit.rs#L250-L253
Now I am not sure which State attributs are needed for fn invoke.