Skip to content

Commit

Permalink
Merge pull request #751 from gwenn/highlighter_attr
Browse files Browse the repository at this point in the history
Fix derive macro with Highlighter attr
  • Loading branch information
gwenn authored Dec 5, 2023
2 parents 3f3538d + 0bebb37 commit 562f64d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 4 additions & 0 deletions examples/input_multiline.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use rustyline::highlight::MatchingBracketHighlighter;
use rustyline::validate::MatchingBracketValidator;
use rustyline::{Cmd, Editor, EventHandler, KeyCode, KeyEvent, Modifiers, Result};
use rustyline::{Completer, Helper, Highlighter, Hinter, Validator};
Expand All @@ -6,11 +7,14 @@ use rustyline::{Completer, Helper, Highlighter, Hinter, Validator};
struct InputValidator {
#[rustyline(Validator)]
brackets: MatchingBracketValidator,
#[rustyline(Highlighter)]
highlighter: MatchingBracketHighlighter,
}

fn main() -> Result<()> {
let h = InputValidator {
brackets: MatchingBracketValidator::new(),
highlighter: MatchingBracketHighlighter::new(),
};
let mut rl = Editor::new()?;
rl.set_helper(Some(h));
Expand Down
4 changes: 2 additions & 2 deletions rustyline-derive/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,8 @@ pub fn highlighter_macro_derive(input: TokenStream) -> TokenStream {
::rustyline::highlight::Highlighter::highlight_candidate(&self.#field_name_or_index, candidate, completion)
}

fn highlight_char(&self, line: &str, pos: usize) -> bool {
::rustyline::highlight::Highlighter::highlight_char(&self.#field_name_or_index, line, pos)
fn highlight_char(&self, line: &str, pos: usize, forced: bool) -> bool {
::rustyline::highlight::Highlighter::highlight_char(&self.#field_name_or_index, line, pos, forced)
}
}
}
Expand Down

0 comments on commit 562f64d

Please sign in to comment.