Commit Graph

1873 Commits (c73b18be77ca73e461a991bf8d30a8c5f95af597)

Author SHA1 Message Date
Wilfred Hughes b95e6cc6e6 Fix Scheme globs 2024-03-04 22:25:16 +07:00
Wilfred Hughes 247727066f Handle whitespace in shebangs 2024-03-04 22:10:08 +07:00
Wilfred Hughes 6ff603cc6e Support some more Scheme file extensions 2024-03-04 22:06:19 +07:00
Wilfred Hughes d5c60241ef Detect more Makefile naming patterns 2024-03-04 22:06:09 +07:00
Wilfred Hughes b78f7d447b Always replace tabs, even in single-column display
Fixes #617
2024-03-04 21:38:23 +07:00
Wilfred Hughes 7ddd8879b1 Merge branch 'scheme-support' of github.com:kutsurak/difftastic into kutsurak-scheme-support 2024-03-04 08:46:59 +07:00
Wilfred Hughes 5e38261b77 cargo fmt 2024-02-29 00:56:16 +07:00
Wilfred Hughes 53298e4240 Set a length limit on lines when doing a word diff
See #653
2024-02-29 00:54:55 +07:00
Wilfred Hughes 7e8f928926 Add doc comments 2024-02-29 00:10:52 +07:00
Brandon Maier e6b27caf06 Add support for devicetrees 2024-02-28 17:11:53 +07:00
Wilfred Hughes 1b2099d7a4 Fix windows build 2024-02-26 20:55:45 +07:00
Wilfred Hughes bb9e864ffe Fix permissions always shown as 'changed' with git-difftool 2024-02-20 00:17:38 +07:00
Wilfred Hughes cbbcbb3094 Parse file mode properly from git and pass through 2024-02-20 00:07:06 +07:00
Wilfred Hughes 1cc0c42c20 Detect git difftool paths and prefer the second argument
Fixes #620
2024-02-19 22:19:20 +07:00
Wilfred Hughes 9032c2ff89
Merge pull request #643 from baz-scm/json-output-respect-unchanged-files
Allow JSON output to respect skip-unchanged
2024-02-19 12:00:59 +07:00
Wilfred Hughes 7a00339977
Merge pull request #634 from evanrichter/smali
Smali language support
2024-02-19 11:57:54 +07:00
Wilfred Hughes bf047030d2 Add a unit tests that validates that all language configs are valid 2024-02-15 08:47:58 +07:00
Nimrod 679d1ce65a Impl PartialEq 2024-02-14 16:13:08 +07:00
Nimrod 9f8d79bb7f Allow JSON output to respect skip-unchanged 2024-02-14 16:08:40 +07:00
Panagiotis Koutsourakis 67ada1ccd4 Add support for Scheme 2024-02-12 10:20:57 +07:00
Rhys Botfield 55b9630069 Add extra PHP file extensions to the language guesser. 2024-02-09 14:43:20 +07:00
Wilfred Hughes cd65d48619 Silence a clippy warning 2024-02-08 08:40:47 +07:00
Wilfred Hughes 4146067be1 Prefer implementing Display over a custom .display() method 2024-02-08 08:34:48 +07:00
Evan Richter d106c979ee add smali language support 2024-02-01 15:41:14 +07:00
Wilfred Hughes 7fda26d68a cargo fmt 2024-01-30 21:25:01 +07:00
Wilfred Hughes 052b3a62a3 Use XML file headers as language detection hints
Fixes #630
2024-01-30 21:22:51 +07:00
Wilfred Hughes 5219977d88 Add comment to language detection logic 2024-01-29 21:57:40 +07:00
Godefroid Chapelle 992f9cf11d
ZCML is XML
Zope and Plone ZCML (Zope Configuration Markup Language) is XML.
2024-01-29 16:40:48 +07:00
Mikhail Brinchuk 297fa952c2
Merge branch 'Wilfred:master' into f# 2024-01-29 11:45:31 +07:00
Mikhail Brinchuk 045344f783 Fixed rust format 2024-01-28 12:52:07 +07:00
Mikhail Brinchuk 0e4723cf0e Added F# support 2024-01-28 12:11:53 +07:00
Armin Brauns c5638750d6 Add tree-sitter-vhdl 2024-01-09 09:23:51 +07:00
Wilfred Hughes 2d61aefb84 Fix tab replacement in single-column display
Fixes #617
2024-01-07 19:35:33 +07:00
Wilfred Hughes 8ad07174c9 Fix spelling 2024-01-07 19:28:29 +07:00
Wilfred Hughes bc0cbaf3ae Change default tab width to 4
This is more consistent with web UIs like GitHub, so I think it's a
better default.
2024-01-07 13:15:12 +07:00
Wilfred Hughes db86b28a28 Add support for Objective-C
Closes #600

Co-authored-by: Nick Moore <nick@pilotmoon.com>
2024-01-07 12:50:19 +07:00
Wilfred Hughes 50a03b4b14
Merge pull request #614 from yuja/push-utqlvwnvuwrl
Fix dir-diff paths merging to not add duplicated entries from remainder
2024-01-05 08:47:24 +07:00
Wilfred Hughes 35a182dd42 Remove bool_to_int_with_if clippy config
This doesn't exist in Rust 1.63 (it was added in 1.65) and 1.67 moved
it to allow-by-default anyway.
2024-01-05 08:39:08 +07:00
Yuya Nishihara 19e21cda90 Fix dir-diff paths merging to not add duplicated entries from remainder
If lhs_paths and rhs_paths are ["a", "c"] and ["a", "b", "c"] respectively, the
loop ends with paths = ["a", "c", "b"], i = j = 2. We still need to deduplicate
"c" from the rhs_paths.

.into_iter() can't be used anymore since the seen set still borrows the paths.
2024-01-02 10:53:18 +07:00
Wilfred Hughes db0c150f61 Report permission changes
Fixes #605
2023-12-30 11:20:00 +07:00
Wilfred Hughes 68f28a8085 More use of renamed over extra_info 2023-12-29 19:51:14 +07:00
Wilfred Hughes b71c553d07 Clarify field that is a path description, not a path 2023-12-29 19:47:39 +07:00
Wilfred Hughes 5d2a4777dc Simlify pattern matches 2023-12-29 19:47:17 +07:00
Wilfred Hughes 8b90c95e01 When called with a single path, require conflict markers
Fixes #585
2023-12-29 19:39:44 +07:00
Wilfred Hughes c180fb52a9 Treat strict types in Haskell as atoms
This isn't ideal: it prevents a finegrained diff of syntax within a type, but it
beats claiming that the code is unchanged.

Fixes #607
2023-12-28 19:24:35 +07:00
Wilfred Hughes 26c58a25e8 Treat regex literals as atoms in Clojure 2023-12-17 10:46:15 +07:00
Wilfred Hughes 72348338aa Style warnings more prominently 2023-12-14 09:07:47 +07:00
Wilfred Hughes 5fd9dfe4a9 Treat *.xsd as XML
Fixes #602
2023-12-08 21:34:07 +07:00
Wilfred Hughes 4a8f983f2f
Merge pull request #579 from rody/feature/salesforce_apex_support
Add salesforce apex support
2023-12-07 08:45:33 +07:00
Yuya Nishihara 8e35c9272c Drop use of AtomicBool from diffing frontend
All diff consumers can now access to a mutable bool.
2023-12-07 08:37:42 +07:00
Yuya Nishihara d04a7cd78b Move diffing job to worker thread instead of printing loop
The scoped thread API allows this change, and I think it's slightly easier
to follow. We can also remove the AtomicBool.
2023-12-07 08:37:42 +07:00
Yuya Nishihara 44578368ab Use scoped thread API in directory diff frontend
Just a code cleanup. As the minimum Rust version is now 1.63.0, we don't need
to manage the spawned thread manually.
2023-12-07 08:37:42 +07:00
Wilfred Hughes 4b0fff2d19 cargo fmt 2023-12-05 08:28:37 +07:00
Rodolphe Blancho e18b5d0712
Merge branch 'master' into feature/salesforce_apex_support 2023-12-05 12:31:59 +07:00
Wilfred Hughes e01b2f9f83 Fix a clippy warning about nested ifs 2023-11-28 13:29:33 +07:00
Wilfred Hughes cac80e992a Avoid `res` locals in favour of more meaningful names 2023-11-28 13:27:27 +07:00
Wilfred Hughes 2adb2f8531 Include rustc version in --version output
Fixes #554
2023-11-28 13:07:33 +07:00
Wilfred Hughes 569f0038d1 Always filter blank lines at start and end in positions
Fixes #595
2023-11-28 12:35:28 +07:00
Wilfred Hughes d89d057345 Clarify parameter name 2023-11-28 11:57:11 +07:00
Wilfred Hughes 08853fa9b6 Clarify comment 2023-11-28 11:34:45 +07:00
Wilfred Hughes e96c9463a0 Fix typo 2023-11-28 11:15:11 +07:00
Wilfred Hughes f31106fddd Fix capitalisation in display name for SCSS 2023-11-24 19:42:16 +07:00
Wilfred Hughes 3e5783c2a7 Treat --sort-paths as a flag option 2023-11-24 01:11:26 +07:00
Nimrod Kor e9a8fda9cb
Skip dirs specified in gitignore (#574)
Take ignored dirs into consideration when calculating diff

Co-authored-by: Nimrod <nimrod@getbaz.com>
2023-11-24 00:48:55 +07:00
Milan Damen a8d6253509
Sort by path before outputting directory diff so that the order is always the same (#593)
* Sort by path before outputting directory diff so that the order is always the same

* Added feature flag --sort-paths (DFT_SORT_PATHS) to enable/disable sorting paths when diffing directory (default disabled)
2023-11-20 10:24:35 +07:00
Wilfred Hughes 1ec868e1df Update to latest line-numbers 2023-11-19 13:11:07 +07:00
Wilfred Hughes 1dbcd08a90 cargo fmt 2023-11-19 13:10:41 +07:00
Wilfred Hughes 8fd79c2885 Remove unused content length calculations 2023-11-18 17:31:40 +07:00
Wilfred Hughes fe62cf4cf5 Don't ignore novel blank lines
Fixes #575
2023-11-18 17:27:41 +07:00
Wilfred Hughes 1138a4623d Remove unused commit_hash struct field 2023-11-18 16:46:13 +07:00
Wilfred Hughes 4c387e4cfe Remove unused struct field 2023-11-18 16:46:13 +07:00
Wilfred Hughes f2b3b34bec Use pub(crate) everywhere for visibility
This isn't strictly necessary since difftastic is a binary-only
crate. However, it improves compiler warnings (see next commit) and
potentially helps future changes to make difftastic available as a
library.
2023-11-18 16:46:13 +07:00
Wilfred Hughes 60d0f61cbd Define a separate words module 2023-11-18 16:46:13 +07:00
Wilfred Hughes 635e62c19b Support .snap files
Closes #571
2023-11-18 14:50:54 +07:00
Wilfred Hughes 2e415f687d cargo fmt 2023-11-11 20:57:41 +07:00
Wilfred Hughes 142144e484 Clarify doc comment 2023-11-11 11:16:52 +07:00
Wilfred Hughes 27b14ae4c7 Clarify probably_punctuation 2023-11-11 11:14:49 +07:00
Wilfred Hughes 7321f663dc Enable some more clippy warnings 2023-11-11 10:48:22 +07:00
Wilfred Hughes 848984d482 Silence some clippy warnings 2023-11-11 10:47:26 +07:00
Wilfred Hughes 778a6bee9a Flatten nullable types in Kotlin
Workaround for #589 and #411
2023-10-26 08:56:37 +07:00
Wilfred Hughes 21ed3ec48b Add missing environment variable for --skip-unchanged
Fixes #581
2023-10-13 08:41:38 +07:00
Wilfred Hughes dfe48a29e1 Format bytes counts in logging in a human-friendly manner 2023-10-11 20:30:01 +07:00
Wilfred Hughes 81714c17ce
Merge pull request #573 from brneor/scss
Add Scss parser
2023-10-11 08:57:58 +07:00
Rodolphe Blancho 5256d9c98e Merge branch 'master' into feature/salesforce_apex_support 2023-10-11 09:56:51 +07:00
Wilfred Hughes 67dbf0e962 Add --strip-cr
Closes #486
2023-10-10 08:36:57 +07:00
Rodolphe Blancho 05d78ca741 add support for Salesforce Apex
Apex Language documentation:
https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_dev_guide.htm

Uses https://github.com/aheber/tree-sitter-sfapex
2023-10-06 11:08:02 +07:00
Wilfred Hughes 992437db1d Show the language name when parsing fails 2023-09-28 00:33:49 +07:00
Wilfred Hughes 40403b2b8f Pass lang_conf with language so they're Some/None together 2023-09-27 23:51:45 +07:00
Wilfred Hughes 00f7ef8522 Improve variable name 2023-09-27 15:49:57 +07:00
Breno Reis 1bffcf4e2b
add support for SCSS 2023-09-20 14:26:43 +07:00
Wilfred Hughes aeb974ba7e Add TODO 2023-09-15 16:06:44 +07:00
Wilfred Hughes 6dd0c70767 Add TODO 2023-09-12 13:05:05 +07:00
Wilfred Hughes 1e7866b64e Do word diffing on text too 2023-09-12 13:03:27 +07:00
Wilfred Hughes 243a4a5f48 Group imports consistently
This corresponds to:

$ cargo +nightly fmt -- --config group_imports=StdExternalCrate

Since this option is only available on nightly, I'm not adding a
rustfmt.toml to enforce this, just doing it as a one-off run.
2023-09-12 12:32:51 +07:00
Wilfred Hughes 8731a1b908 Fix rustdoc warnings 2023-09-12 12:21:43 +07:00
Wilfred Hughes f3ba79f34d Qualify all difftastic imports with crate:: 2023-09-12 12:17:58 +07:00
Wilfred Hughes f06c611ed7 More XML file patterns 2023-09-09 10:18:11 +07:00
Wilfred Hughes d6fe1221a4 Add *.ui to the XML file extensions 2023-09-09 10:07:11 +07:00
Wilfred Hughes 577bb99228 Treat XSLT as XML 2023-09-09 00:12:22 +07:00
Wilfred Hughes 004a0da67f Flatten modifiers in C# to improve highlighting 2023-09-08 23:44:11 +07:00
Wilfred Hughes 9134593a39 Add XML support
Fixes #10
2023-09-08 23:43:20 +07:00
Wilfred Hughes d56f775f31 Highlight constructors consistently with type names 2023-09-03 01:30:22 +07:00
Wilfred Hughes a4ee2cf99e cargo fmt 2023-08-26 21:41:41 +07:00
Wilfred Hughes b78ba2da4b Use type names from line_numbers directly 2023-08-26 20:36:07 +07:00
Wilfred Hughes 41c9165c79 Use my line_numbers crate for newline position calculations 2023-08-26 16:25:32 +07:00
Wilfred Hughes ca44de78e1 Group overrides from the same language together
No functional change, but makes --list-languages easier to read.

Fixes #549
2023-08-25 08:22:28 +07:00
Wilfred Hughes 0db99d76c6 Allow a language override to include multiple globs 2023-08-24 08:47:59 +07:00
eth3lbert b6d8ecbd4f
feat: display commit info in --version (#558)
This improves --version output for #554.
2023-08-18 08:10:47 +07:00
Wilfred Hughes 803a3a673c Improve variable names 2023-08-18 00:28:17 +07:00
Alex Krantz 11a96e5aec Add JSON cli flag 2023-08-17 08:49:59 +07:00
Wilfred Hughes 11f457b5f9 Fix typo 2023-08-16 21:20:17 +07:00
Wilfred Hughes 191f42e9d5 Clippy fixes 2023-08-15 21:42:06 +07:00
Wilfred Hughes 6b1c82efdf Prefer Option<&T> over &Option<T> 2023-08-15 21:37:41 +07:00
Wilfred Hughes a43b9ae9eb Dim the extra information section in hunks 2023-08-15 21:33:11 +07:00
Wilfred Hughes e1f97e614f Improve wording of conflict information
Fixes #555
2023-08-15 17:52:02 +07:00
Wilfred Hughes e0a1405453 Add the ability to parse conflict markers and diff the two files 2023-08-15 09:01:15 +07:00
Wilfred Hughes f06e95ca02 Renamed `old_path` to `extra_info` and format it during option parsing
This allows us to use this field for other purposes that aren't
renames.
2023-08-14 08:41:42 +07:00
Wilfred Hughes f1ba399504 Move local variable closer to first use 2023-08-14 08:27:42 +07:00
Wilfred Hughes eeb2974967 Move option parsing before argument parsing
This is useful for additional mode parsing that wants to access these
options.
2023-08-13 21:34:42 +07:00
Wilfred Hughes 1c60f3efd3 Move content detection out of diff_file_content
This makes the function useful in cases when we already have a string,
not bytes.
2023-08-13 21:31:37 +07:00
Wilfred Hughes 3c702d0490 Use humansize for file size formatting 2023-08-12 22:34:11 +07:00
Wilfred Hughes 5f25bc0ebd Rename information in header should only be shown on first hunk
Fixes #553
2023-08-11 08:21:29 +07:00
Wilfred Hughes a187d7a134 Improve rename styling
It should use the heading with colour, consistent with other modes,
and the header should come before rename information.
2023-08-08 08:53:33 +07:00
Wilfred Hughes ba92a93f9b Fix rustc warning on recent nightly 2023-08-04 23:31:31 +07:00
Wilfred Hughes 19cbf1d458 Implement some other useful traits on EqOnFirstItem
These aren't immediately used, but they're handy for experimenting
with the similar library which requires these.
2023-08-04 23:29:29 +07:00
Wilfred Hughes 892d4fdb58 Ensure size_hint never exceeds graph_limit
If we have thousands of syntax nodes on both sides, we can end
up attempting to preallocate a very large hashmap.

In #542, a user hit an issue with two JSON files where the LHS had
33,000 syntax nodes and the RHS had 34,000 nodes, so we'd attempt to
preallocate a hashmap of capacity 1,122,000,000. This required
allocating 70,866,960,400 bytes (roughly 66 GiB).

Impose a sensible limit on the hashmap.

Fixes #542
2023-08-04 17:19:27 +07:00
Wilfred Hughes c937f819a1 Log the number of bytes in the arena at the end of route finding 2023-08-04 17:04:23 +07:00
Wilfred Hughes 0c01c73398 Be consistent in lifetime names for Vertex 2023-08-03 08:32:16 +07:00
Wilfred Hughes 757c297412 Adjust header style
Show the hunk count and detected language in a dimmed style. This
information is less important than the diff content itself, so this
change makes the important information more prominent.

First part of #544
2023-07-31 08:35:27 +07:00
Wilfred Hughes 797af40ae8 Improve Java highlighting 2023-07-27 08:33:38 +07:00
Wilfred Hughes 4e9637c861 Check more bytes when detecting encoding
I've observed PDF files that have sufficiently large headers that they
were detected as text, which wasn't helpful.

Also improve logging to report how many invalid bytes were found.
2023-07-21 08:34:41 +07:00
Wilfred Hughes 4f750ec359 Clarify how to find language names in argument help 2023-07-21 08:23:36 +07:00
Wilfred Hughes 685a2ef8d5 Merge remote-tracking branch 'grunweg/master' 2023-07-20 22:41:56 +07:00
Wilfred Hughes 7caaaf7fcf Handle nested sliders correctly when preferring the outer delimiter
Previously we didn't check the state of children, which was an
oversight from the original implementation. As a result, we fixed
nested sliders in fewer situations.

Fixes #535
2023-07-14 08:49:55 +07:00
Wilfred Hughes a5d3cb55b7 Treat constructors consistently with variables in Haskell atoms 2023-07-12 17:34:42 +07:00
Wilfred Hughes 8614910fe2 cargo fmt 2023-07-12 16:45:58 +07:00
Wilfred Hughes f6ceb2aefd Update unit test new subword highlighting heuristic 2023-07-12 12:48:45 +07:00
Wilfred Hughes 5606c04261 Treat qualified modules and variables as atoms in Haskell 2023-07-12 12:34:39 +07:00
Wilfred Hughes a814e01d22 Improve word diffing heuristic and add another sample file 2023-07-12 12:12:32 +07:00
Wilfred Hughes 1d3b6836ef Handle multiline atoms more accurately in split_atom_words 2023-07-12 11:49:39 +07:00
Wilfred Hughes c2b7042b80 Do subword highlighting in more cases
This is useful when two strings substantially differ, but have the
same e.g. end.
2023-07-10 21:26:24 +07:00
Wilfred Hughes 5824322244 Require some common words to do subword highlighting
This is important when comparing short string literals. This change
has improved several cases in sample_files/ but I've added a new
example that made the previous unwanted behaviour much more obvious.
2023-07-10 09:03:21 +07:00
Wilfred Hughes 4aca79f220 Use the raw_entry_mut API on hashbrown::HashMap
This saves us searching the hash map twice. This is a modest
performance improvement: an instruction count reduction of 4% on
slow_before.rs, and 1% reduction on typing_before.ml.
2023-07-09 22:49:37 +07:00
Wilfred Hughes 8eb949eb02 Use DftHashMap everywhere
This is a 4% reduction in instructions for typing_before.ml, but a
0.2% increase instructions for slow_before.rs. This seems like a win
overall, and it also keeps the codebase more consistent and simpler.
2023-07-09 15:41:01 +07:00
Wilfred Hughes d9911e0b49 Move DftHashMap to a separate file 2023-07-09 15:37:51 +07:00
Wilfred Hughes f2456a12b2 Use hashbrown for the alloc_if_new data
This was intended to allow usage of .entry_ref(), but it's already a
performance win without using that API! It's around a 9% reduction in
instructions in slow_before.rs, and 2% reduction in typing_before.ml.
2023-07-09 11:11:03 +07:00
Wilfred Hughes 27f59c0b3a Don't treat - as a word constituent
This produces slightly better results with some string replacements.
2023-07-08 17:16:14 +07:00
Wilfred Hughes 2607d17d73 Fix spelling in comment 2023-07-08 17:16:14 +07:00
Zhenge Chen ffd49d523a Detect replaced strings
If a string is replaced with another, apply subword highlighting
similar to how we handle replaced comments.

Co-authored-by: Wilfred Hughes <me@wilfred.me.uk>
2023-07-08 17:16:06 +07:00
Wilfred Hughes f86ba13abf Increase punctuation cost to 200 2023-07-08 14:59:47 +07:00