binding: Restore handling of multiple symbols w/ same name

Even though normal aliases don't cause this, simple (single-use) aliases still do cause it.
This commit is contained in:
Max Brunsfeld 2019-03-05 09:44:43 -08:00
parent f52271352b
commit 445dfda53e
2 changed files with 73 additions and 39 deletions

View file

@ -3,7 +3,7 @@ mod escape;
use serde::{Deserialize, Deserializer, Serialize, Serializer};
use serde_derive::*;
use std::cmp;
use std::fmt::Write;
use std::fmt::{self, Write};
use std::mem::transmute;
use std::str;
use std::usize;
@ -572,8 +572,9 @@ where
}
}
impl<'a, T: Fn(&str) -> Option<(Language, &'a PropertySheet<Properties>)>> Iterator
for Highlighter<'a, T>
impl<'a, T> Iterator for Highlighter<'a, T>
where
T: Fn(&str) -> Option<(Language, &'a PropertySheet<Properties>)>,
{
type Item = HighlightEvent<'a>;
@ -653,6 +654,31 @@ impl<'a, T: Fn(&str) -> Option<(Language, &'a PropertySheet<Properties>)>> Itera
}
}
impl<'a, T> fmt::Debug for Highlighter<'a, T>
where
T: Fn(&str) -> Option<(Language, &'a PropertySheet<Properties>)>,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
if let Some(layer) = self.layers.first() {
let node = layer.cursor.node();
let position = if layer.at_node_end {
node.end_position()
} else {
node.start_position()
};
write!(
f,
"{{Highlighter position: {:?}, kind: {}, at_end: {}, props: {:?}}}",
position,
node.kind(),
layer.at_node_end,
layer.cursor.node_properties()
)?;
}
Ok(())
}
}
impl<'a> Layer<'a> {
fn new(
source: &'a [u8],