Open zesterer opened 6 months ago
Actually, my mistake: it seems that the default implementation of the highlight_char
method returns false
in all cases, so I needed to override this. I do think this is unexpected behaviour though: if not overriding it leads to incorrect behaviour, it should either (a) have a default implementation that does produce correct behaviour (return true
) or (b) not have a default implementation.
I'll keep the issue open since this still seems like an unexpected default behaviour.
As explain in highlight_char
, rustyline must refresh the whole buffer at each key stroke if set to true
.
You can can try to input a very large multiline input buffer and do some random change or just move the cursor.
I expect you to see some slowness...
I definitely understand that argument, but that only demonstrates that providing a default implementation of those methods is problematic: it took me quite a while to figure out that there was a method I was, in fact, supposed to override in order to produce the correct behaviour.
I'm implementing some simple syntax highlighting based on
example.rs
. Syntax highlighting only seems to occur once backspace is pressed, and not after each keystroke (i.e: the input line appears unhighlighted until I press backspace at the end of the line, triggering a highlight).At first I thought this was an issue in my own code, but I confirmed this to not be the case by placing
if line.len() > 0 { panic!(); }
within the body of myHighlighter::highlight
function (the> 0
check is just to prevent a panic happening once at startup). As suspected, rustyline allows me to input whatever characters I want, only panicking if backspace is pressed.