|
|
|
@ -476,9 +476,16 @@ impl<'a> Hash for Syntax<'a> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Debug, Clone, Copy)]
|
|
|
|
|
|
|
|
pub enum HighlightKind {
|
|
|
|
|
|
|
|
Normal,
|
|
|
|
|
|
|
|
Comment,
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
|
|
|
#[derive(PartialEq, Eq, Debug, Clone)]
|
|
|
|
pub enum MatchKind {
|
|
|
|
pub enum MatchKind {
|
|
|
|
Unchanged {
|
|
|
|
Unchanged {
|
|
|
|
|
|
|
|
highlight: HighlightKind,
|
|
|
|
opposite_pos: (Vec<SingleLineSpan>, Vec<SingleLineSpan>),
|
|
|
|
opposite_pos: (Vec<SingleLineSpan>, Vec<SingleLineSpan>),
|
|
|
|
},
|
|
|
|
},
|
|
|
|
Novel,
|
|
|
|
Novel,
|
|
|
|
@ -576,6 +583,7 @@ fn split_comment_words(
|
|
|
|
impl MatchedPos {
|
|
|
|
impl MatchedPos {
|
|
|
|
fn new(
|
|
|
|
fn new(
|
|
|
|
ck: ChangeKind,
|
|
|
|
ck: ChangeKind,
|
|
|
|
|
|
|
|
is_comment: bool,
|
|
|
|
pos: Vec<SingleLineSpan>,
|
|
|
|
pos: Vec<SingleLineSpan>,
|
|
|
|
prev_opposite_pos: Vec<SingleLineSpan>,
|
|
|
|
prev_opposite_pos: Vec<SingleLineSpan>,
|
|
|
|
) -> Vec<Self> {
|
|
|
|
) -> Vec<Self> {
|
|
|
|
@ -610,7 +618,14 @@ impl MatchedPos {
|
|
|
|
Atom { position, .. } => (position.clone(), position.clone()),
|
|
|
|
Atom { position, .. } => (position.clone(), position.clone()),
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
MatchKind::Unchanged { opposite_pos }
|
|
|
|
MatchKind::Unchanged {
|
|
|
|
|
|
|
|
highlight: if is_comment {
|
|
|
|
|
|
|
|
HighlightKind::Comment
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
HighlightKind::Normal
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
opposite_pos,
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Novel => MatchKind::Novel,
|
|
|
|
Novel => MatchKind::Novel,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
@ -683,6 +698,7 @@ fn change_positions_<'a>(
|
|
|
|
|
|
|
|
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
change,
|
|
|
|
change,
|
|
|
|
|
|
|
|
false,
|
|
|
|
open_position.clone(),
|
|
|
|
open_position.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
@ -708,11 +724,17 @@ fn change_positions_<'a>(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
change,
|
|
|
|
change,
|
|
|
|
|
|
|
|
false,
|
|
|
|
close_position.clone(),
|
|
|
|
close_position.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
Atom { info, position, .. } => {
|
|
|
|
Atom {
|
|
|
|
|
|
|
|
info,
|
|
|
|
|
|
|
|
position,
|
|
|
|
|
|
|
|
is_comment,
|
|
|
|
|
|
|
|
..
|
|
|
|
|
|
|
|
} => {
|
|
|
|
let change = info
|
|
|
|
let change = info
|
|
|
|
.change
|
|
|
|
.change
|
|
|
|
.get()
|
|
|
|
.get()
|
|
|
|
@ -733,6 +755,7 @@ fn change_positions_<'a>(
|
|
|
|
}
|
|
|
|
}
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
positions.extend(MatchedPos::new(
|
|
|
|
change,
|
|
|
|
change,
|
|
|
|
|
|
|
|
*is_comment,
|
|
|
|
position.clone(),
|
|
|
|
position.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
prev_opposite_pos.clone(),
|
|
|
|
));
|
|
|
|
));
|
|
|
|
|