Fix subword highlighting in multiline comments

pull/70/head
Wilfred Hughes 2021-11-14 16:48:55 +07:00
parent 6e955793db
commit 546391e9c0
2 changed files with 14 additions and 1 deletions

@ -36,6 +36,11 @@ usage.
Updated to latest upstream Haskell parser ([commit
666808](https://github.com/tree-sitter/tree-sitter-haskell/commit/6668085e7d3dc6205a3ef27e6293988cf4a10419)).
### Diffing
Fixed a bug when diffing multiline comments where unchanged parts were
not highlighted correctly.
## 0.11
### Parsing

@ -533,9 +533,10 @@ pub struct MatchedPos {
pub pos: SingleLineSpan,
}
// "foo bar" -> vec!["foo", " ", "bar"]
fn split_words(s: &str) -> Vec<String> {
lazy_static! {
static ref RE: Regex = Regex::new(r"[a-zA-Z0-9]+|[^a-zA-Z0-9]+").unwrap();
static ref RE: Regex = Regex::new(r"[a-zA-Z0-9]+|\n|[^a-zA-Z0-9\n]+").unwrap();
}
RE.find_iter(s).map(|m| m.as_str().to_owned()).collect()
@ -898,4 +899,11 @@ mod tests {
let res = split_words(s);
assert_eq!(res, vec!["example", ".", "com"])
}
#[test]
fn test_split_words_treats_newline_separately() {
let s = "example.\ncom";
let res = split_words(s);
assert_eq!(res, vec!["example", ".", "\n", "com"])
}
}