Commit Graph

717 Commits (711d39975806233ce505abcea45998170d402579)

Author SHA1 Message Date
Wilfred Hughes 6f1a069a75 Document usage of tree-sitter 2021-08-16 22:30:12 +07:00
Wilfred Hughes 414182c9dd Only show a single column in side-by-side when adding a whole file 2021-08-08 23:25:26 +07:00
Wilfred Hughes 09a80150df Fix adding/removing whole files
The 'remove unaligned lines at beginning of hunk' logic meant we just
discarded the whole hunk.

This breaks alignment again (previously fixed in 3ebbf268fd), but that
should be fixed properly in the padding logic.
2021-08-08 23:15:23 +07:00
Wilfred Hughes 3ae0b7df84 Allow RHS to be arbitrarily long in a pager
If stdout is not a TTY, assume it's a pager and don't truncate the
RHS.
2021-08-08 17:35:31 +07:00
Wilfred Hughes 857cb77d8f Ensure LHS and RHS source code are the same width 2021-08-08 17:31:18 +07:00
Wilfred Hughes 83b8c843cb Use .. for column numbers on blank lines used to align 2021-08-08 11:26:17 +07:00
Wilfred Hughes 1ceaecfa25 Remove --width from CLI parameters
This is the first step in refactoring for inline diffs.
2021-08-01 15:30:12 +07:00
Wilfred Hughes 2e6666041f Contiguous novel atoms are always better than changing depth of novel lists 2021-07-31 23:32:23 +07:00
Wilfred Hughes 34f084d8f1 Calculate content width based on visible lines 2021-07-31 17:21:55 +07:00
Wilfred Hughes e67732bab9 Improve contiguous novel logic
Inspect the previous syntactic node, then get the atom position, open
delimiter position or close delimiter position depending on the
context.
2021-07-31 16:54:14 +07:00
Wilfred Hughes a4751b98f1 Fix a parsing issue with -> in Rust 2021-07-31 01:25:16 +07:00
Wilfred Hughes 573cd32a01 Prefer matching comments that are similar
Previously, we'd match up any pair of comments with a levenstein
distance of 0.4 or more. This was reasonably effective, but misssed
opportunities even more precise diffs.

Instead, prefer the comment matching with the highest levenshtein
distance.

We still only highlight word-level changes for comments with a
levenshtein of 0.4 or more.

Closes #27
2021-07-30 22:54:30 +07:00
Wilfred Hughes da63704675 Roll version 2021-07-28 00:04:47 +07:00
Wilfred Hughes 6f2140e901 Replace tabs with spaces before parsing
Difftastic uses offsets to store the positions of AST nodes, so we
cannot replace tabs after parsing.

A string literal with a tab character "	" being replaced by a four
space string literal "    " is now ignored by difftastic. This is
wrong: difftastic should only ignore whitespace between atoms.

This is still an improvement for source code that uses tab characters,
which is common in Go. The above case should be rare until we have a
full solution.

Fixes #24
2021-07-27 23:36:20 +07:00
Wilfred Hughes a7f688ee82 Put a spacer between LHS and RHS lines printed
Width calculations already consider the spacer, but it was lost in a
refactor.
2021-07-27 22:02:48 +07:00
Wilfred Hughes f24c4954bc Update changelog for previous commit 2021-07-27 22:01:38 +07:00
Wilfred Hughes 7701e38510 Add a basic Go parser 2021-07-25 23:46:33 +07:00
Wilfred Hughes e36a2e8c96 Don't crash on binary files 2021-07-25 12:50:42 +07:00
Wilfred Hughes c8481775e2 Remove --context CLI argument 2021-07-25 12:34:50 +07:00
Wilfred Hughes 04214ef1ef Ignore indentation changes on multiline comments 2021-07-25 12:27:24 +07:00
Wilfred Hughes 3ebbf268fd Improve alignment when LHS and RHS have different numbers of lines 2021-07-24 18:01:12 +07:00
Wilfred Hughes 928584676a Only highlight individual comment words for comments that are similar 2021-07-24 17:01:30 +07:00
Wilfred Hughes 3f8e41d862 Parse @ in elisp 2021-07-24 16:50:53 +07:00
Wilfred Hughes 45af6b4534 Parse < and > as symbols in elisp 2021-07-24 16:45:06 +07:00
Wilfred Hughes 2da5181ffb Prefer replacing comments over novel atoms
This was broken in 4c33f34.
2021-07-24 16:36:36 +07:00
Wilfred Hughes 6d7e155cc6 Remove unused CLI parameter 2021-07-24 16:27:33 +07:00
Wilfred Hughes b81312e88b Roll version 2021-07-22 00:09:13 +07:00
Wilfred Hughes 5d2c14a3f9 Entering a list should set the prev_novel state to the open delimiter 2021-07-22 00:07:09 +07:00
Wilfred Hughes 61446c916a Prefer marking large subtrees as novel rather than largely novel
This solves the "replace function A with completely different function
B" problem, even if they start with the same function keyword.
2021-07-21 01:05:01 +07:00
Wilfred Hughes c48e8e2977 Improve JS and JSON parsing 2021-07-20 01:18:39 +07:00
Wilfred Hughes 7bd8afc439 Improve handling of = and & in lisps 2021-07-20 01:09:29 +07:00
Wilfred Hughes aa28b26f48 Basic support for non-UTF8 source files 2021-07-20 00:46:12 +07:00
Wilfred Hughes 2d9efe15a0 Fix another crash on empty files
Git history with file additions/removals should now work.
2021-07-20 00:22:01 +07:00
Wilfred Hughes 6bec8b7e2c Don't crash on files without an extension 2021-07-20 00:10:58 +07:00
Wilfred Hughes 49ec9d68cc Improve OCaml parsing for := and !
Fixes #20
2021-07-19 23:04:03 +07:00
Wilfred Hughes 6fb01cf7d3 Lex string literals with escaped delimiters 2021-07-18 23:42:36 +07:00
Wilfred Hughes ad81a86419 + is a legal symbol constituent in elisp 2021-07-18 23:40:46 +07:00
Wilfred Hughes 88b0ec2283 & is legal in elisp
It's used for variadic functions.
2021-07-18 23:25:56 +07:00
Wilfred Hughes 75839a1185 Support # and . in lisps
Elisp uses # for sharp-quoting, and some Schemes use # for vector
literals.

. is used for dotted pair notation.
2021-07-18 23:18:55 +07:00
Wilfred Hughes 28d5e51911 Fix crash on multibyte characters
Previously parsing would proceed byte at a time, which would crash if
the source contained multibyte characters. Instead, try all the
regular expression patterns, and jump to the next nearest match.
2021-07-18 22:34:52 +07:00
Wilfred Hughes 5f4ab7c292 Support using difftastic with built-in git commands 2021-07-18 15:01:32 +07:00
Wilfred Hughes abddca0b46 Dijkstra visits nodes in distance order, so we only need predecessors
The first time we see a node, we've found the shortest path to it. Add
it to the predecessors then, and don't visit it again.
2021-07-17 17:53:59 +07:00
Wilfred Hughes 1c9ece441a Improve --help 2021-07-17 14:18:40 +07:00
Wilfred Hughes cdc70dd784 Add ReplaceComment edge and display a word diff between the comments 2021-07-17 13:55:41 +07:00
Wilfred Hughes 00fcd4652a Recognise # and <- as OCaml punctuation
Fixes #18
2021-07-15 23:54:53 +07:00
Wilfred Hughes a2e36cac46 Add more two-character lexems to Rust parser 2021-07-13 23:36:52 +07:00
Wilfred Hughes 4c79267602 Roll version 2021-07-13 23:27:17 +07:00
Wilfred Hughes 8b382e4356 Improved OCaml handling
Fixes #17
Fixes #15
2021-07-13 22:52:13 +07:00
Wilfred Hughes 74c2b8e901 Clarify slider and performance status 2021-07-13 22:31:13 +07:00
Wilfred Hughes fbb2dffd4a Store an ID on Syntax values and use it for vertex equality 2021-07-13 21:49:40 +07:00
Wilfred Hughes b2d9035774 Consider nesting depth when comparing nodes 2021-07-10 17:42:02 +07:00
Wilfred Hughes 5c644baf7c Treat .. as a single atom in Rust 2021-07-10 17:13:07 +07:00
Wilfred Hughes 4cf2a24997 Fixed crash on multibyte characters that include '\n'
Fixes #13
2021-07-09 23:37:04 +07:00
Wilfred Hughes bbc77b8cbc Organise changelog by area 2021-07-09 23:35:53 +07:00
Wilfred Hughes ce35a5cc3a Support $( ... ) and $foo in Rust
Closes #14
2021-07-09 22:54:11 +07:00
Wilfred Hughes 1dc6ab3977 Fix crash when diff touches first line 2021-07-08 01:10:37 +07:00
Wilfred Hughes 094133fe10 Ensure that we display all context lines, even if matched pairs are unordered 2021-07-07 23:45:22 +07:00
Wilfred Hughes 9e821956a5 Roll version 2021-07-07 22:25:03 +07:00
Wilfred Hughes 6f87140703 Don't crash if file is unchanged
Fixes #4
2021-07-07 22:19:46 +07:00
Wilfred Hughes c43e724caf Ensure :: is treated as a single token in Rust 2021-07-07 22:02:20 +07:00
Wilfred Hughes da8a4c1ee1 Line up visible lines and include gaps if necessary 2021-07-07 22:01:19 +07:00
Wilfred Hughes 5463c120f4 Better punctuation parsing for JS and OCaml
Closes #7
2021-07-07 19:53:45 +07:00
Wilfred Hughes ccaca6f6a6 Rust: Consider , as separate punctuation
Closes #8
2021-07-07 19:51:49 +07:00
Wilfred Hughes 483fe8ca51 Ensure we always find the shortest route
Previously we would ignore shorter routes if we'd already found a
route to the node.
2021-07-04 22:38:17 +07:00
Wilfred Hughes 76ef7c510c Teach syntax about Rust lifetimes 2021-07-04 12:59:17 +07:00
Wilfred Hughes 64bfc73a6c Roll version for next release 2021-07-04 11:42:59 +07:00
Wilfred Hughes 9cd63c972d Adding a changelog 2021-07-04 11:40:31 +07:00