Commit Graph

274 Commits (646ab39cbb88a8d226f0553511000a141d7d7b2e)

Author SHA1 Message Date
Wilfred Hughes 646ab39cbb Mention that Janet is supported 2022-03-29 19:50:25 +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 b6cd8c9a42 Update Clojure highlighting to match upstreamed PR
See https://github.com/sogaiu/tree-sitter-clojure/pull/20
2022-03-26 23:50:55 +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 bacefe5a58 Roll version 2022-03-26 16:02:51 +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 c9c3582871 Print incrementally when diffing directories
Fixes #170
2022-03-22 09:51:23 +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 68f3ab2b92 Don't consider lines with whitespace to have missing syntax
Fixes #171
2022-03-20 19:49:13 +07:00
Wilfred Hughes 12ee2c7673 Warn if both arguments are the same path
Fixes #164
2022-03-20 15:14:14 +07:00
Wilfred Hughes 2fd48800c7 Update changelog for previous commit 2022-03-20 15:06:13 +07:00
Ömer Sinan Ağacan a2488f984c Add support for Dart 2022-03-20 11:07:32 +07:00
Wilfred Hughes 9435798c9c Next release will be 0.24 2022-03-19 10:27:04 +07:00
Wilfred Hughes 06ffa0267a Next release will be a patch release with a single crash fix 2022-03-19 10:24:30 +07:00
Wilfred Hughes d06f357c93 Fix crash when outer delimiters are discarded when skipping unchanged
If we skip some nodes inside a list whose delimiters are unchanged, we
need to mark the outer list as unchanged.

Split ChangeState::Unchanged into UnchangedNode and UnchangedDelimiter
to make this clearer, and add a test.
2022-03-18 16:00:05 +07:00
Wilfred Hughes b5187d98d0 Roll version 2022-03-17 22:22:42 +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 d709aa98b5 Fix typo 2022-03-15 21:52:09 +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 8c469e3d36 Ensure slider correction sets the opposite node on both sides
Fixes #154
2022-03-13 21:23:58 +07:00
Wilfred Hughes 19d11951ce Update changelog for c0d1faae6 2022-03-13 20:26:59 +07:00
Wilfred Hughes afb1b369f4 Switch to wu-diff for textual diffing
In #153 a user reported difftastic never terminated on a 140,000
file. This was due to the diff crate using a very large amount of time
and memory.

The diff crate does not use Myers' algorithm, which has a
divide-and-conquer approach using snakes:

https://blog.jcoglan.com/2017/03/22/myers-diff-in-linear-space-theory/

wu-diff does implement Myer's algorithm and performs much better on
these large files.
2022-03-10 23:12:25 +07:00
Wilfred Hughes a3a2bfb317 Roll version 2022-03-10 00:13:26 +07:00
Wilfred Hughes ed0bde6b91 Adding support for PHP 2022-03-09 23:52:31 +07:00
Wilfred Hughes 0927a2f9e6 Update changelog 2022-03-09 23:11:04 +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 f82cace9bd Atom content equality should ignore highlighting
Improves several cases in #147
2022-03-05 11:37:10 +07:00
Wilfred Hughes 2d4ec0a4be Bump minimum Rust version to 1.56 for rpds support 2022-03-05 10:42:52 +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 cb0f1f3fe5 Roll version 2022-02-28 09:26:26 +07:00
Wilfred Hughes 128bad9ac9 Fix typo 2022-02-26 11:47:30 +07:00
Wilfred Hughes ea7d6b7257 Fix Unicode handling in word splitting 2022-02-24 09:36:51 +07:00
Wilfred Hughes 3aa9a48b25 Parse Emacs file headers when doing language detection
Fixes #145
2022-02-23 22:51:52 +07:00
Wilfred Hughes 562c215a06 Fix crash when a line-wrapped line has no styles
Fixes #142
2022-02-21 19:44:20 +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 d8e8e12bf8 Roll version 2022-02-20 16:50:05 +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 84a2dc2dac Fix missing context on misaligned hunks
Fixes #134
2022-02-12 12:26:00 +07:00
Wilfred Hughes 46301dbfa5 Don't crash on zero arguments 2022-02-12 11:04:52 +07:00
Wilfred Hughes ab1071cfda Increase the default value of DFT_NODE_LIMIT
Closes #136
2022-02-11 21:54:24 +07:00
Wilfred Hughes e561cdf580 Terminate after displaying a single column. 2022-02-08 23:50:15 +07:00
Wilfred Hughes 76fc3118ac Introduce a byte limit for files that are too big to parse
Default limit is 1 MB.

Fixes #131.
2022-02-08 23:44:50 +07:00