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

Highlighter::highlight_char doesn't distinguish between edits and cursor movement #332

Closed
thomcc opened this issue Feb 11, 2020 · 4 comments · Fixed by #812
Closed

Highlighter::highlight_char doesn't distinguish between edits and cursor movement #332

thomcc opened this issue Feb 11, 2020 · 4 comments · Fixed by #812

Comments

@thomcc
Copy link
Contributor

thomcc commented Feb 11, 2020

The highlight_char docs say: "Tells if line needs to be highlighted when a specific char is typed or when cursor is moved under a specific char".

I'm reading this to mean it's called both on cursor movement and on line edits, but I don't think there's a way to tell which is happening in the current API. For my use case, line edits require re-style, but cursor movements generally would not...

@gwenn
Copy link
Collaborator

gwenn commented Feb 11, 2020

Indeed, currently you cannot make the distinction.
highlight_char was introduced to avoid refreshing the whole line except when you type (or move on) a specific char (like ')' to highlight the matching pair).

@thomcc
Copy link
Contributor Author

thomcc commented Feb 12, 2020

This seems unfortunate, as a lot of cases would only need to repaint when the text changes, and not on movement.

@gwenn
Copy link
Collaborator

gwenn commented Feb 12, 2020

pub trait Highlighter {
...
    /// Due to current limitations (no incremental parsing, no partial repaint, flickers),
    /// `Hightlighter::highlight` is not called when a character is inserted at the end of the line.
    /// If you want highlighting to be updated each time a character is typed, just overwrite this method.
    fn highlight_while_typing(&self) -> bool {
        false
    }
}

?

@thomcc
Copy link
Contributor Author

thomcc commented Feb 12, 2020

Yes, although I'm realizing the larger issue is the repainting/rehighlighting on every change...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants