clippy improvements
This commit is contained in:
@@ -29,6 +29,12 @@ pub struct SyntectEngine {
|
|||||||
line_hashes: Vec<u64>,
|
line_hashes: Vec<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for SyntectEngine {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl SyntectEngine {
|
impl SyntectEngine {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let ps = SyntaxSet::load_defaults_newlines();
|
let ps = SyntaxSet::load_defaults_newlines();
|
||||||
@@ -179,17 +185,14 @@ impl SyntectEngine {
|
|||||||
let s = provider.field_value(i);
|
let s = provider.field_value(i);
|
||||||
|
|
||||||
// Fix: parse_line takes 2 arguments: line and &SyntaxSet
|
// Fix: parse_line takes 2 arguments: line and &SyntaxSet
|
||||||
let ops = match ps.parse_line(s, &self.ps) {
|
let ops = ps.parse_line(s, &self.ps).unwrap_or_default();
|
||||||
Ok(ops) => ops,
|
|
||||||
Err(_) => Vec::new(), // Handle parsing errors gracefully
|
|
||||||
};
|
|
||||||
|
|
||||||
// Fix: HighlightState::new requires &Highlighter and ScopeStack
|
// Fix: HighlightState::new requires &Highlighter and ScopeStack
|
||||||
let mut highlight_state = HighlightState::new(&highlighter, stack.clone());
|
let mut highlight_state = HighlightState::new(&highlighter, stack.clone());
|
||||||
|
|
||||||
// Fix: HighlightIterator::new expects &mut HighlightState as first parameter
|
// Fix: HighlightIterator::new expects &mut HighlightState as first parameter
|
||||||
let mut it = HighlightIterator::new(&mut highlight_state, &ops[..], s, &highlighter);
|
let it = HighlightIterator::new(&mut highlight_state, &ops[..], s, &highlighter);
|
||||||
while let Some((_style, _text)) = it.next() {
|
for (_style, _text) in it {
|
||||||
// Iterate to apply ops; we don't need the tokens here.
|
// Iterate to apply ops; we don't need the tokens here.
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,19 +244,16 @@ impl SyntectEngine {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Fix: parse_line takes 2 arguments: line and &SyntaxSet
|
// Fix: parse_line takes 2 arguments: line and &SyntaxSet
|
||||||
let ops = match ps.parse_line(line, &self.ps) {
|
let ops = ps.parse_line(line, &self.ps).unwrap_or_default();
|
||||||
Ok(ops) => ops,
|
|
||||||
Err(_) => Vec::new(), // Handle parsing errors gracefully
|
|
||||||
};
|
|
||||||
|
|
||||||
// Fix: HighlightState::new requires &Highlighter and ScopeStack
|
// Fix: HighlightState::new requires &Highlighter and ScopeStack
|
||||||
let mut highlight_state = HighlightState::new(&highlighter, stack);
|
let mut highlight_state = HighlightState::new(&highlighter, stack);
|
||||||
|
|
||||||
// Fix: HighlightIterator::new expects &mut HighlightState as first parameter
|
// Fix: HighlightIterator::new expects &mut HighlightState as first parameter
|
||||||
let mut iter = HighlightIterator::new(&mut highlight_state, &ops[..], line, &highlighter);
|
let iter = HighlightIterator::new(&mut highlight_state, &ops[..], line, &highlighter);
|
||||||
|
|
||||||
let mut out: Vec<StyledChunk> = Vec::new();
|
let mut out: Vec<StyledChunk> = Vec::new();
|
||||||
while let Some((syn_style, slice)) = iter.next() {
|
for (syn_style, slice) in iter {
|
||||||
if slice.is_empty() {
|
if slice.is_empty() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user