Commit Graph

205 Commits (565e2f12a3e852ca65c26d52c2708a621095d6f7)

Author SHA1 Message Date
Wilfred Hughes 39bd04002c
Merge pull request #369 from esawady/hare
Add Hare support
2022-09-15 09:33:07 +07:00
Wilfred Hughes cafd672cc8 Don't underline all changes in plaintext files
Fixes #371
2022-09-15 09:30:16 +07:00
Ember Sawady 7ed685ae52 Add support for Hare 2022-09-13 23:34:16 +07:00
Wilfred Hughes 3c51f58d8e Add Pascal support
Fixes #365
2022-09-13 00:05:23 +07:00
Wilfred Hughes f155a27522 Underline changed words in comments
This makes them easier to spot in larger changes.

Fixes #328
2022-09-10 15:54:04 +07:00
Yuya Nishihara 84f0b25fb6 Add support for QML
QML is a UI language, and its syntax is basically JSON-like structure
+ JavaScript. The tree-sitter parser is named after the upstream grammar
file qmljs.g, but the canonical language name is QML. So I choose Qml as
the Language enum.

https://doc.qt.io/qt-6/qmlapplications.html
2022-09-10 11:38:35 +07:00
Wilfred Hughes fe5ef8757d Give novel punctuation a lower edge cost
We'd rather see an unchanged variable name than an unchanged comma.

Fixes #366
2022-09-09 09:47:53 +07:00
Wilfred Hughes b104c4be10 Fix sliders in a single global pass
Previously we fixed sliders in each 'possibly changed' region. This
meant that we couldn't fix sliders that needed to move outside the
region. The most common case was code of the form `foo, bar, baz`
where `, baz` was unchanged but we wanted to slide to `,`.

We now call `fix_all_sliders` for the toplevel tree on both
sides. This required some minor changes to the slider logic, as the
unchanged/novel regions could occur at any level of the tree.

(It was probably also the case that we were missing slider
opportunities previously, because we terminated as soon as we found an
outer slider for the nested case.)

This change has no performance impact, probably because tree diffing
is vastly more expensive (O(N^2)) than sliders (O(N)).

Fixes #327
2022-09-02 18:10:09 +07:00
Wilfred Hughes eabefd5612 Factor out language name pretty-printing 2022-09-02 11:56:51 +07:00
Wilfred Hughes b1b3756fa7 Attempt to detect and decode UTF-16 files too
Closes #345
2022-08-28 15:38:57 +07:00
Wilfred Hughes 09334030ab Fix incorrect line number being used in side-by-side display
Fixes #334
2022-08-22 09:34:34 +07:00
Wilfred Hughes 026b2674d0 Update expected output
The previous two commits were done in a branch that was rebased, so
the integration tets missed 5fe6d551d.
2022-08-21 21:36:00 +07:00
Wilfred Hughes c957818514 Explore two graph nodes for each parenthesis position
This produces substantially better diff results, and fixes the 'last
item in the list shown as changed' problem.

This can produce slower diffing. typing_before.ml takes 10% more
instructions and slow_before.rs takes 110% more instructions.
2022-08-21 16:34:17 +07:00
Wilfred Hughes a71d6118cf Store predecessors and neighbours as mutable fields in graph nodes
This is a more traditional graph representation. It is slightly easier
to reason about, and it's clearer that graph node creation time
dominates graphs exploration.

This is a slight performance regression, but it enables better
exploration of parethesis nesting (see next commit). typing_before.ml
has regressed from 3.75B instructions to 3.85B instructions and
slow_before.rs has regressed from 1.73B instructions to 2.15B
instructions.

This change has also made the diff output for slow_before.rs slightly
worse (note the `lhs` variable is now claimed as changed in more
cases). It's not clear why, but presumably means that the node visit
order has changed slightly.

Closes #324
2022-08-21 16:25:54 +07:00
Wilfred Hughes 58c8f47298 Also consider highlights.scm when marking nodes as comments
This removes the need to special-case Perl, and is necessary for
CMake (which has nodes bracket_comment and line_comment that aren't
marked as 'extra').
2022-08-20 18:28:07 +07:00
Wilfred Hughes 01cce54978 Fix path display when called from git with two arguments
Fixes #332
2022-08-18 23:00:13 +07:00
Wilfred Hughes 0dce9fcec5 Update regression tests following 38c6718c86 2022-07-11 22:14:12 +07:00
Wilfred Hughes 7e34d7073b Update regressio tests for new JSON upstream highlighting 2022-07-10 23:36:11 +07:00
Wilfred Hughes c5a5555862 Update Gleam parser 2022-07-10 22:58:50 +07:00
Wilfred Hughes d05a3d9373 Add Julia sample files 2022-07-04 19:57:00 +07:00
Wilfred Hughes 975ff6eedd Update regression tests now that @conditional is highlighted
This is mostly `if` keywords in various positions now being
highlighted as keywords.
2022-07-04 19:54:00 +07:00
Wilfred Hughes 719654d462
Merge pull request #301 from lilydjwg/master
use unicode-width to align CJK characters
2022-07-04 15:07:25 +07:00
Wilfred Hughes 156c701459 Add large files from #293 for test
This file pair exposed a bunch of perf issues, so it's useful to keep
it around.
2022-07-03 22:18:30 +07:00
Wilfred Hughes 2d43075841 HTML: include doublequotes in attribute atoms 2022-07-03 22:11:25 +07:00
lilydjwg 0648b0a6cf add sample_files for Chinese (CJK fullwidth characters)
One of the other three "expected" updates is caused by a fullwidth emoji
and others are removal of colored empty strings.
2022-07-04 12:01:49 +07:00
Benjamin Manns d131ae1d35 Add HTML parser 2022-07-01 12:23:20 +07:00
Wilfred Hughes 3eada5b9b0 Prefer outer delimiter in lisps 2022-05-11 11:54:02 +07:00
Wilfred Hughes ca1dbbc264 Update expected output file for 902c30f6c 2022-05-11 11:45:48 +07:00
Wilfred Hughes 1a6c5b8e7f Display rename information when before and after paths are different 2022-05-08 11:52:42 +07:00
Wilfred Hughes 2d8e1cf180
Merge pull request #279 from Xuanwo/fix_bad_padding
fix: Bad padding of column numbers at the end of files
2022-05-07 11:27:47 +07:00
cherryblossom defc084637
Add Elvish support
Add support for [Elvish](https://elv.sh).
2022-05-07 20:12:43 +07:00
Xuanwo 5cfe53820b
chore: Update compare expected
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-05-03 14:45:25 +07:00
Wilfred Hughes 03c5d78650 Treat perl regexes as atoms too 2022-04-29 18:28:01 +07:00
Wilfred Hughes 3bb5933163 Ensure Perl comments are treated as atoms with an atom kind of comment 2022-04-29 18:23:31 +07:00
Wilfred Hughes e1cbdc1478 Allow users to override the tab width
Fixes #274
2022-04-28 20:47:04 +07:00
cherryblossom b87d6c99f7
Add Swift support 2022-04-26 17:08:23 +07:00
Wilfred Hughes b2320b29d5
Merge pull request #264 from Xuanwo/hcl
feat: Add HCL support
2022-04-24 08:48:34 +07:00
Xuanwo d4c3d114dc
fix: Add atoms for hcl
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-04-24 15:57:51 +07:00
Wilfred Hughes f91357b729 Update perl regression test 2022-04-23 11:33:01 +07:00
Xuanwo 5a7ca84455
feat: Add highlights support for hcl
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-04-23 01:55:44 +07:00
Xuanwo 4b3213acdc
feat: Add HCL support
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-04-23 01:10:08 +07:00
Xuanwo 20289dfe91
fix: Expected compare not updated
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-04-22 19:00:00 +07:00
Xuanwo b85f996ff0
feat: Add perl support
Signed-off-by: Xuanwo <github@xuanwo.io>
2022-04-22 10:14:19 +07:00
Wilfred Hughes a91a3e5db0 Handle namespaced highlighting queries 2022-04-18 09:35:09 +07:00
Wilfred Hughes aa14b60933 Update regression test for 8 space indent 2022-04-17 20:15:34 +07:00
Wilfred Hughes 2b7a97f322 Update regression tests for latest rust parser
`&` highlighting has improved, and one case of a `;` match moving
slightly.
2022-04-17 19:25:23 +07:00
Wilfred Hughes 3289fe0075 Add a C++ test file 2022-04-17 16:33:20 +07:00
Wilfred Hughes 3b36271959 Split large lists that are mostly unchanged
Fixes #156
2022-04-17 15:54:27 +07:00
Wilfred Hughes 6b24e28c28 Add support for TOML 2022-04-14 21:21:36 +07:00
Wilfred Hughes 1a93162740 Fix block sclars in YAML 2022-04-14 18:45:48 +07:00
Wilfred Hughes 47fe0cfc42 Add some more common keyword-ish capture names for highlighters 2022-04-14 00:40:09 +07:00
Wilfred Hughes b3872e6513 Add syntax highlighting and regression test for Kotlin 2022-04-14 00:38:44 +07:00
Wilfred Hughes 1830d286e0 Ensure unchanged MatchedPos have the same number on LHS and RHS
Fixes #246
2022-04-09 21:12:31 +07:00
Wilfred Hughes 1c9ae2fbc6 Fix parsing of built-in Zig identifiers
Fixes #248
2022-04-09 19:38:07 +07:00
Wilfred Hughes 053de5acbe Update to Clojure parser with separate symbol positions
See discussion in https://github.com/sogaiu/tree-sitter-clojure/issues/21
2022-04-09 12:41:49 +07:00
Wilfred Hughes 838ad0c048 Add regression test for #181 2022-04-09 12:18:51 +07:00
Wilfred Hughes 1c416733ef Fix nested sliders in C-like languages
Improves #165
2022-04-08 09:41:56 +07:00
Wilfred Hughes bdb68cd676 Support @boolean and @character highlighting queries 2022-04-03 22:36:15 +07:00
Wilfred Hughes 10a0e2dba9 Improve YAML handling
Fix atom handling and add syntax highlighting
2022-04-03 22:26:33 +07:00
Wilfred Hughes 9245aada8f Merge remote-tracking branch 'alexmanno/add_yaml_support'
Closes #208
2022-04-03 22:08:44 +07:00
Alex Perkins f5ab6e7e86
add newline to module exports 2022-04-03 21:37:17 +07:00
Alex Perkins d6e9afd3d6 add support for Elm 2022-04-03 20:18:33 +07:00
Wilfred Hughes 01678f8556 Don't pad the right column in side-by-side display
Helps with #209 too.
2022-04-03 11:30:19 +07:00
Wilfred Hughes 81db99e51e Update regression test for Gleam 2022-04-03 10:50:54 +07:00
Wilfred Hughes 28c6e35943 Merge #205 2022-04-02 17:18:59 +07:00
Jacob Rothstein 9945270f4b
add gleam
# Conflicts:
#	CHANGELOG.md
#	README.md
2022-03-31 14:08:05 +07:00
Andrew Gutekanst 6c2504a34f Add expected Zig diff results for CI check 2022-03-31 12:38:17 +07:00
Alessandro Manno b2dd6c5aa8
fixed compare.expected 2022-03-30 19:36:27 +07:00
Wilfred Hughes ecdf993ff1 Add support for Nix
Closes #196
2022-03-29 22:46:09 +07:00
Jafar eb29b824c3
Merge branch 'master' into pr-add_lua_parser 2022-03-30 06:23:20 +07:00
JafarAbdi b850d41fa5 Add lua support 2022-03-30 06:21:10 +07:00
sogaiu e1e735752d Add sample files and update compare.expected 2022-03-29 14:53: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