-
Notifications
You must be signed in to change notification settings - Fork 178
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
Is it possible for a Highlighter to re-render a line to undo cursor-based highlights? #726
Comments
I was able to get the behavior I want by adding an additional "needs_final_refresh" method into Is there a way to do this in a more appropriate way? Or what design would you like to see in a PR? Thanks again. |
We already refresh the line here: Lines 28 to 32 in 1c4091a
But indeed currently, we cannot check / know that the Highlighter needs a final refresh.
|
If adding a method to the |
No worry, we can add a new method to |
…atchingBracketHighlighter to re-render line without highlighting. Issue kkawakam#726
I tried to tie up this logic nicely in a PR, and I added the below method to the fn final_highlight(&self, line: &str) -> bool But I realized there is a complication. The internal-mutability pattern (ie I followed this pattern and used the There are several solutions but I only see one that doesn't involve changing the client-facing API or contract in some way.
I raised a PR (#727) with the "least risky" change, but it feel like a little hackish so I understand if you have a better idea for a fix. Thank you. |
Thanks for your investigation.
See draft #729 |
Yeah. I think this is a better solution. I just didn't feel personally comfortable enough changing the behavior of the editor state and trait method definitions, but you have more knowledge and I like your solution better. My one nit is that I was thinking of it as "final" instead of "forced" (or |
In fact, this is not necessarily the final refresh because depending on |
That is a good point. really it's a matter of the cursor position being non-existent after the line has been accepted. So you could make the Thank you again. |
Version 13.0.0 released. |
Thank you very much! |
Consider the HistoryHinter example here: https://github.com/kkawakam/rustyline/blob/master/examples/example.rs which uses the
MatchingBracketHighlighter
.If you type
( x )
, it will bold-blue the first '(', as it should, when the closing ')' is typed. But if you then hitEnter
, the '(' remains bold-blued on the now-complete line.I have tried to fix this with my own implementation of a Highligher object, but neither the
highlight_char
nor thehighlight
Highlighter methods are called again on that original line. (They are called on a new line with a len=0, pos=0)Is there a way (perhaps with the
Validator
?) to get the editor to re-render the line one last time? I see people may not want this as the default behavior if their tty speed is limited, but is there a way to make it happen?Thank you.
The text was updated successfully, but these errors were encountered: