revdiff
revdiff copied to clipboard
A .jsonata file can freeze revdiff at 100% CPU (chroma v2.27.0 JSONata lexer)
revdiff freezes on a .jsonata file when a line has a character that no rule of chroma's JSONata lexer matches: an unmatched ' or ", or a |. The process stays at 100% CPU and ignores q.
Reproduce (revdiff 1.13.0; 1.15.0 and master use the same chroma v2.27.0):
printf 'diff --git a/f.jsonata b/f.jsonata\nnew file mode 100644\n--- /dev/null\n+++ b/f.jsonata\n@@ -0,0 +1,3 @@\n+a\n+it'"'"'s\n+b\n' > /tmp/j.patch
revdiff --stdin < /tmp/j.patch # press j: it freezes
Git mode freezes too, on valid JSONata with the transform operator: $ ~> |$|{"a": 1}|.
Expected: the file opens. Actual: revdiff hangs.
Cause: the last rule of chroma's lexers/embedded/jsonata.xml, [a-zA-Z0-9_]*, matches the empty string, so the lexer stops moving forward. chroma fixed this loop in its engine (alecthomas/chroma#1382), in v3.0.0-alpha.6 but not in v2.27.0.