Commit Graph

34 Commits (b850d41fa571d97c7de071b5bd759cd908c19f73)

Author SHA1 Message Date
JafarAbdi b850d41fa5 Add lua support 2022-03-30 06:21:10 +07:00
Wilfred Hughes f26ca24df7 Discard '\n' nodes in C and C++
These are from the preprocessor grammar rules, but they're not useful
for difftastic.

Reported upstream: https://github.com/tree-sitter/tree-sitter-c/issues/97

Closes #180
2022-03-27 23:37:23 +07:00
Wilfred Hughes ec2b72bff2 Update regression tests for previous commit 2022-03-26 23:50:33 +07:00
Wilfred Hughes 1d7324c2dc Clarify wording when a parsed file has no changes at all 2022-03-26 23:31:12 +07:00
Wilfred Hughes 92b9680ecd Define a scala.scm of highlighting queries 2022-03-26 23:26:21 +07:00
Wilfred Hughes 5b1bc62ac6 Don't show hunk numbers when there's only one hunk
Related: #60
2022-03-26 22:52:04 +07:00
Wilfred Hughes 2b36a755f0 Ensure that blank lines in multiline strings are shown as changed
Fixes #121
2022-03-23 22:47:17 +07:00
Wilfred Hughes f15ec6d637 Lower the default node limit for tree diffing
Fixes #176
2022-03-22 21:15:54 +07:00
Wilfred Hughes 4647112e93 Define a highlighting file for Clojure
This isn't provided upstream, and the parse tree doesn't have a lot of
information, but we can at least handle string literals and keywords.
2022-03-22 21:08:46 +07:00
Wilfred Hughes 9e32e2e08e Ensure matched lines includes blanks at the ends of the file
Fixes #163
2022-03-20 22:31:32 +07:00
Wilfred Hughes a18dce036a Handle novel MatchedPos values that have unchanged values on the same line
Fixes #169
2022-03-20 15:03:22 +07:00
Wilfred Hughes 29050f00ce Configure language and fix highlighting for dart 2022-03-20 11:36:12 +07:00
Wilfred Hughes e38d14a144 Prefer aligning blank lines in display
After we've aligned lines based on diff results, we have intermediate
lines that we need to align somehow. Previously, we'd just take them
in order, aligning the first on the LHS with the first on the RHS and
so on.

If the intermediate lines start or end with a sequence of blank lines,
prefer aligning the blank lines. If we have both, arbitrarily choose
the ending blank lines.

This has produced better results in many of the sample files, although
in the case of slow_before.rs we've just changed from a leading blank
line alignment to a trailing blank line alignment.
2022-03-17 22:16:45 +07:00
Wilfred Hughes 6d58247465 Preserve the outer delimiter when shrinking
Previously, we'd always discard the outer delimiter if it matched on
both sides. This prevented the tree diff finding optimal diffs.

Fixes #124
2022-03-16 23:38:05 +07:00
Wilfred Hughes 40d3ccd06c Fix confusion between byte length and codepoint length in styling
We should split lines based on their codepoint length, so all our
lengths are on codepoint boundaries. We can then safely index by byte position.

All the positions are measured in bytes, not code points. Tweak
function names to make this explicit.

Fixes #149
2022-03-15 09:50:13 +07:00
Wilfred Hughes b2229d66a8 Always display all lines in a hunk
Previously we were assuming that the first/last line pairs in a hunk
contained the earliest/latest lines on both sides. This isn't true
when there are no common items between the lines.

This fixes some display issues in load_before/after.js, but include a
new integration test that is smaller and easier to eyeball.

Fixes #133
2022-03-15 00:11:30 +07:00
Wilfred Hughes c0d1faae63 Keep exploring the graph even when we find matched delimiters
Previously we'd get tripped up by cases where choosing equal
delimiters would be be considered the same as entering each delimiter
separately, making diffs worse.

Fixes #147
2022-03-13 15:41:54 +07:00
Wilfred Hughes 2f8ccd94da Add sample file showing slow perf large adjacent lists
Part of #156.
2022-03-12 11:28:28 +07:00
Wilfred Hughes 17ff2bc07e < and > are delimiters in Rust and C++ 2022-03-08 20:42:57 +07:00
Wilfred Hughes 88ae00bd88 Use depth difference as a heuristic when comparing equal nodes
This reverts commit 7544874a55. It turns
out there are cases where this is still necessary (see new sample
file). It's also performance neutral.

This bug became more obvious with the recent 'skip unchanged'
optimisations. The optimisation changed the number of preceeding nodes and
exposed this bug more often.
2022-03-08 09:44:55 +07:00
Wilfred Hughes 6f65bbbbb0 Merge branch 'delim_type'
Introduce a new type EnteredDelimiter that tracks entering/leaving
list nodes. The PopEither and PopBoth cases reflect the choices more
accurately than a 2-tuple of options.

This is a performance hit (slow_before.rs runtime has increased by
49%) but it's important for diff correctness.

Fixes #147
2022-03-06 21:39:15 +07:00
Wilfred Hughes e134257f78 Fix syntax error in clojure example program 2022-03-05 16:31:47 +07:00
Wilfred Hughes 44b2f6b6ec Update regression tests for empty atom change in previous commit 2022-03-05 16:31:30 +07:00
Wilfred Hughes f82cace9bd Atom content equality should ignore highlighting
Improves several cases in #147
2022-03-05 11:37:10 +07:00
Wilfred Hughes 25433a0c3d Only consider novel trees at the top level
Helps with #148. On my machine this changes slow_after.rs from 4.4 to
3.4 seconds, but only reduced instruction count from 12.8B to 10.4B.

The one changed case in sample_files/ is more granular and more
readable.
2022-03-02 22:55:22 +07:00
Wilfred Hughes 0905fb74c3 Simplify usage of regression test suite 2022-02-24 20:35:36 +07:00
Wilfred Hughes f1063bd1e7 Ensure we consider all unchanged nodes for calculating alignment
Fixes #141
2022-02-20 22:41:29 +07:00
Wilfred Hughes 54fd04a7e2 Ensure regression test always uses the same width 2022-02-20 20:28:06 +07:00
Wilfred Hughes ca55c7ee2c Update integration test expectation following 7544874a5 2022-02-20 20:25:49 +07:00
Wilfred Hughes 82890923cd Track entering/leaving parents explicitly
This produces significantly better diffs, and fixes some cases that
were outright wrong before.

Fixes #30
2022-02-20 12:43:52 +07:00
Wilfred Hughes 692f08f1f1 Merge hunks when lines are adjacent 2022-02-19 16:12:04 +07:00
Wilfred Hughes d8cc1168b1 Make sample files naming consistent so they're all used in regression test 2022-02-13 17:21:20 +07:00
Wilfred Hughes f4b0d2f584 Rename JS sample file 2022-02-13 17:18:39 +07:00
Wilfred Hughes 66f41c7053 Add reference file for current output hashes 2022-02-13 17:15:41 +07:00