Commit Graph

329 Commits (efec7595047557eacf73c0e61103fa6532770ebc)

Author SHA1 Message Date
Wilfred Hughes 974a7bd765 Remove unused import 2022-04-29 12:02:32 +07:00
Wilfred Hughes dc51e154b8 Choose colour mode when parsing options 2022-04-28 21:10:26 +07:00
Wilfred Hughes 005f62c5b0 Group display options into a single struct 2022-04-28 21:07:12 +07:00
Wilfred Hughes e1cbdc1478 Allow users to override the tab width
Fixes #274
2022-04-28 20:47:04 +07:00
Wilfred Hughes f98f2a8aca Fix directory diffing when files were only present on one side
This particularly helps usage with mercurial when files are added or
removed.

Fixes #272
2022-04-27 21:46:46 +07:00
Wilfred Hughes a7aa0ae00b Merge branch 'change_state_outside' 2022-04-24 20:25:04 +07:00
Wilfred Hughes ee0f1ee7f2 Diff files in directories in parallel 2022-04-24 20:17:47 +07:00
Wilfred Hughes 394e1a3482 Define a ChangeMap struct 2022-04-24 12:06:08 +07:00
Wilfred Hughes 6a900f4a88 Remove .change accessor 2022-04-24 11:46:30 +07:00
Wilfred Hughes 625e9935e1 Stop change state from being public on Syntax 2022-04-24 11:03:13 +07:00
Wilfred Hughes f644e7a5f0 Pass change_map through 2022-04-24 10:53:13 +07:00
Wilfred Hughes 715d71b6b4 Set deep in changes.rs 2022-04-24 10:49:49 +07:00
Wilfred Hughes a3e944df0d Define a separate changes file 2022-04-24 10:36:15 +07:00
Wilfred Hughes 34fd5ba7eb Render tabs with 8 spaces (previously 4)
Most web UIs seem to do this (e.g. on GitHub), and C code from the
Linux kernel assumes 8 spaces in a tab when aligning things.
2022-04-17 20:13:53 +07:00
Wilfred Hughes 3b3d5a64a2 Include timestamps in logs 2022-04-17 19:34:14 +07:00
Wilfred Hughes 1c416733ef Fix nested sliders in C-like languages
Improves #165
2022-04-08 09:41:56 +07:00
Wilfred Hughes 83bee32bb4 Move Side to a separate file, document and improve naming 2022-04-03 11:13:45 +07:00
Wilfred Hughes e472acb805 Add a --language option to override language detection
Fixes #199
2022-04-01 23:10:48 +07:00
Wilfred Hughes 97b9a13d15 Expose a proper `--display` CLI option
This helps with discovery of the different display options available,
such as inline (see #34).
2022-04-01 22:15:24 +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 c9c3582871 Print incrementally when diffing directories
Fixes #170
2022-03-22 09:51:23 +07:00
Wilfred Hughes 905fc9ec8b Ignore the trailing newline in source files
This should have produced a change in output, but it's currently
ignored due to #163.
2022-03-20 22:26:44 +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 a51b81e86d cargo fmt 2022-03-17 20:45:09 +07:00
Wilfred Hughes eb59e15cd8 Silence some of the noisier clippy lints 2022-03-17 20:13:27 +07:00
Wilfred Hughes f4f12003cb Fix minor clippy lints 2022-03-16 22:42:31 +07:00
Wilfred Hughes dbf088bd25 cargo fmt 2022-03-12 12:22:38 +07:00
Wilfred Hughes edee567e61 Factor out a myers_diff module 2022-03-12 12:15:59 +07:00
Wilfred Hughes dba68d1d2a Don't run syntax highlighting when dumping the tree-sitter output
For large files, tree-sitter syntax highlighting is much more
expensive than the parse itself. We spend most of the runtime
advancing the tree-sitter query cursor.

This doesn't affect runtime of normal usage, but it helps debugging
and makes flamegraphs more readable.

Spotted in #153
2022-03-12 11:53:39 +07:00
Wilfred Hughes 1895df8f3b Allow unchanged nodes to be checked recursively, and hook up to main.rs 2022-03-09 09:40:53 +07:00
Wilfred Hughes fb7d2d7c86 Get basic examples working with impl 2022-03-09 09:40:53 +07:00
Wilfred Hughes e2c65e5743 unique ID and plumb in 2022-03-09 09:40:53 +07:00
Wilfred Hughes efc59360cc Add a debugging option to disable the skip_unchanged logic 2022-03-04 09:45:25 +07:00
Wilfred Hughes 75bca2bc57 Fix more clippy warnings 2022-02-24 20:49:11 +07:00
Wilfred Hughes 3c1c5649f4 Ensure --color is still respected
This was broken in the port to owo_colors. owo_colors does not have a
global override: the override function only affects if_supports_color.
2022-02-13 16:54:57 +07:00
Wilfred Hughes a190d3e591 Add TODO 2022-02-08 23:47:28 +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
Wilfred Hughes 85f2d7aa4b Print each hunk immediately
This gives the user output sooner and is very marginally faster
overall too. It's also slightly less code.

Closes #128
2022-02-07 21:40:56 +07:00
Wilfred Hughes 2f591b9b86 Log the number of nodes when we exceed the limit 2022-02-07 09:33:50 +07:00
Wilfred Hughes 67d296c47d Improve wording for textual diffing headers 2022-02-06 17:27:00 +07:00
Wilfred Hughes dd85457b5e Move options parsing into a separate file 2022-02-06 16:58:07 +07:00
Wilfred Hughes e2832dabb3 Set a maximum size on syntactic diffing, and use line diffing otherwise
Fixes #82
2022-02-06 16:38:55 +07:00
Wilfred Hughes d81b774621 Remove unused arguments 2022-02-06 14:37:22 +07:00
Wilfred Hughes 1873267ffa Prefer full module names when calling similar functions 2022-02-06 14:31:03 +07:00
Wilfred Hughes 9e48b64d2c Add a --missing-as-empty flag to allow non-existent paths
By default, difftastic now errors if paths don't exist.
2022-02-03 21:26:51 +07:00
Wilfred Hughes 635ef12f84 Clarify why we return early 2022-02-03 21:05:54 +07:00
Wilfred Hughes 0dcb76eec1 Report whether a binary file has changed
Fixes #119
2022-02-03 21:03:50 +07:00
Wilfred Hughes ea24dd8784 Skip unchanged delim and find a fixpoint
This lets us discard more nodes before diffing, improving performance.

Fixes #84
2022-01-30 17:20:24 +07:00
Wilfred Hughes 4223dd883c Tweak comment wording 2022-01-30 14:25:15 +07:00
Wilfred Hughes 4fa00d5d11 Consistent casing in help 2022-01-30 11:22:11 +07:00
Wilfred Hughes 712f4c0bba Print a more helpful message when called with the wrong number of arguments 2022-01-30 11:16:25 +07:00
Wilfred Hughes 760b54e0cf Improve help text
Don't hard code the binary name, and use "you" consistently.
2022-01-29 23:24:45 +07:00
Wilfred Hughes 82ce1ab818 Add a --skip-unchanged flag
Closes #98
2022-01-29 23:06:42 +07:00
Wilfred Hughes dabaddd709 Discuss usage in --help 2022-01-29 16:32:53 +07:00
Wilfred Hughes 037b8bd6cc Use upper case for positional arguments in help too 2022-01-29 16:22:02 +07:00
Wilfred Hughes 36c4520025 Provide an environment variable for controlling background colour
Fixes #55
2022-01-29 16:07:31 +07:00
Wilfred Hughes c38b072fd2 Add a --background option
Improves #55
2022-01-29 15:58:51 +07:00
Wilfred Hughes 0abc839481 Consistent casing for argument value placeholders 2022-01-29 15:45:11 +07:00
Wilfred Hughes ebd923acbe Use project and author information from Cargo.toml
Prevents duplication.
2022-01-29 15:38:44 +07:00
Wilfred Hughes 2762e35cf9 Prefer long argument help text
This displays the help text on a separate line to the argument name,
which is more readable.
2022-01-29 15:38:00 +07:00
Wilfred Hughes 203a0c3d70 cargo fmt 2022-01-29 15:36:49 +07:00
Wilfred Hughes 0eeb91d591 Add a --color CLI option 2022-01-29 12:38:31 +07:00
Wilfred Hughes c15e4d0cd5 Remove needless variable 2022-01-29 12:19:04 +07:00
Wilfred Hughes ad9cb5beb4 Clarify which options are for debugging in --help 2022-01-29 12:18:11 +07:00
Wilfred Hughes c0ba12bf68 Add a --width CLI argument 2022-01-29 12:13:21 +07:00
Wilfred Hughes d37a233b39 Use clap for parsing dump-syntax and dump-ts options 2022-01-29 12:10:35 +07:00
Wilfred Hughes d0fce4c42f Add a unit test for clap args configuration 2022-01-29 11:14:06 +07:00
Wilfred Hughes 934be78573 Fix clap deprecation warnings 2022-01-29 11:06:44 +07:00
Wilfred Hughes 5a2e0379aa Update to clap 3 2022-01-29 11:01:36 +07:00
Wilfred Hughes 4d8d258837 Clarify argument names 2022-01-29 10:28:18 +07:00
Wilfred Hughes bf5d9b6192 Print header on every hunk in inline display
See #34
2022-01-26 22:05:52 +07:00
Wilfred Hughes e123cad49e Only set next/prev on potentially changed syntax nodes
Otherwise we end up running dijkstra on nodes at the end that we've
already marked as unchanged, and erroneously claim they're novel.

Fixes #112
2022-01-25 22:29:19 +07:00
Wilfred Hughes 440c94ce3c Don't treat identical text files as binary
Looks like a copy-paste mistake.
2022-01-24 20:34:34 +07:00
Wilfred Hughes d594901d29 Factor out a struct for tracking highlighting IDs 2022-01-23 11:38:37 +07:00
Wilfred Hughes a5de97a63c Add syntax highlighting for strings
Improves #32.
2022-01-23 11:27:29 +07:00
Wilfred Hughes 94e968b660 Ignore unchanged nodes at the start/end of the file
This is the first part of #84.
2022-01-22 22:26:52 +07:00
Wilfred Hughes c1b08f8e46 cargo fmt 2022-01-21 22:10:39 +07:00
Wilfred Hughes 3548c32a4c Fix sliders after diffing
Fixes #35
2022-01-21 21:39:02 +07:00
Wilfred Hughes 02a25ff251 Improve perf when diffing identical contents
Should help with #98.
2022-01-18 23:34:31 +07:00
Wilfred Hughes f46345b7f4 More clippy fixes 2022-01-17 12:30:32 +07:00
Wilfred Hughes c05572b0f1 Ignore a noisy clippy warning 2022-01-17 11:38:51 +07:00
Wilfred Hughes f7626ba249 cargo fmt 2022-01-15 10:27:53 +07:00
Wilfred Hughes e404c0e86f Ensure we only calculate opposite positions once
Previously this was computed per-hunk, which was wasteful and slow
when there are many hunks.
2022-01-14 09:48:40 +07:00
Wilfred Hughes d240bfeebd Fix Mercurial when whole file has been removed
Mercurial gives us the path even when it doesn't exist. Just require
at least one of the paths to exist, rather than both.

(Git gives us /dev/null in this situation.)

Fixes #50
2022-01-07 09:42:56 +07:00
Wilfred Hughes 027856d707 Adding a line-based textual differ that ignores trees 2022-01-05 09:39:19 +07:00
Wilfred Hughes c7c6f1a7b6 Print a newline on binary files, consistent with other files 2022-01-03 23:56:34 +07:00
Wilfred Hughes aec3a86a02 Use the longest file for language detection 2021-12-27 17:36:47 +07:00
Wilfred Hughes 9e3c6a7c9d Use shebang (if present) to detect language type 2021-12-27 17:33:14 +07:00
Wilfred Hughes 640cf6723b Add todo 2021-12-27 17:19:50 +07:00
Wilfred Hughes f6f9f16e9f Separate language detection from tree-sitter configuration 2021-12-27 12:18:46 +07:00
Wilfred Hughes 909656398e Print to stderr when reporting errors, even with debugging flags 2021-12-27 12:06:43 +07:00
Wilfred Hughes ca47e6592b Fix typo 2021-12-27 12:05:58 +07:00
Wilfred Hughes abb6bd9657 Fix needless borrows 2021-12-27 12:03:58 +07:00
Wilfred Hughes 6f40d54e27 Use Path arguments when we're dealing with paths 2021-12-26 10:55:38 +07:00
Wilfred Hughes 4883edd90c Factor out a DiffResult type
This separates diffing and printing better, and will make it easier to
provide a JSON output for #73.
2021-12-21 23:44:55 +07:00
Wilfred Hughes d417fc9ae1 Print string contents of tree-sitter leaf nodes 2021-12-07 23:09:07 +07:00
Wilfred Hughes 37c6cc2875 Remove accidental dbg 2021-11-30 22:40:33 +07:00
Wilfred Hughes 5445608ab4 Adding debug logs when diffing whole directories
Should help with #53
2021-11-30 09:40:32 +07:00
Wilfred Hughes 45dd29c822 Cleanup comment 2021-11-30 09:26:15 +07:00
Wilfred Hughes 4a9c6a5044 Improve docstrings in main.rs 2021-11-21 19:20:37 +07:00