Log a warning on parse errors

Fixes #62
pull/70/head
Wilfred Hughes 2021-12-04 18:01:16 +07:00
parent 87c486742c
commit d9e149decc
2 changed files with 11 additions and 0 deletions

@ -10,6 +10,10 @@ Expanded filename associations, so difftastic recognises more files.
Improved word diffing on punctuation in comments.
When logging is enabled (e.g. `RUST_LOG=warn`), difftastic now warns
on syntax errors. Difftastic is intended to be robust against syntax
errors, so this is primarily intended for parser debugging.
## 0.12
### Display

@ -447,6 +447,13 @@ fn syntax_from_cursor<'a>(
) -> &'a Syntax<'a> {
let node = cursor.node();
if node.is_error() {
let position = nl_pos.from_offsets(node.start_byte(), node.end_byte());
let content = &src[node.start_byte()..node.end_byte()];
warn!("Tree-sitter syntax error at {:?}: {}", position.get(0), content);
}
if config.atom_nodes.contains(node.kind()) {
// Treat nodes like string literals as atoms, regardless
// of whether they have children.