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

Adding final_highlight method to Highlighter trait. Issue 726 #727

Closed
wants to merge 2 commits into from

Conversation

luketpeterson
Copy link

Adding final_highlight method to Highlighter trait,
Updating MatchingBracketHighlighter to re-render line without highlighting

Issue #726

Thank you.

…atchingBracketHighlighter to re-render line without highlighting. Issue kkawakam#726
}
}
Borrowed(line)
}

fn highlight_char(&self, line: &str, pos: usize) -> bool {
if pos == 0 || line.len() != pos {
Copy link
Collaborator

@gwenn gwenn Aug 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems wrong to me.
Maybe the following line is the culprit:

s.edit_move_buffer_end()?;

copy.replace_range(idx..=idx, &format!("\x1b[1;34m{}\x1b[0m", matching as char));
return Owned(copy);
// highlight matching brace/bracket/parenthesis if it exists, and this isn't the final render
if !self.is_final.get() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could have been added on line 127 above:

        if line.len() <= 1 || self.is_final().get() {
            return Borrowed(line);

@luketpeterson
Copy link
Author

I like your solution in #729 better. So I'll close this PR if you plan to merge that one.

Thanks a lot!

@gwenn gwenn closed this Sep 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants