Commit Graph

31 Commits (8953c55cf854ceac2ccb6ece004d6a94a5bfa122)

Author SHA1 Message Date
Wilfred Hughes 8953c55cf8 Pass String to new_atom
This is a very tiny perf hit, but allows us to pass newly allocated
strings to new_atom(), which will be necessary for normalising
case-insensitive languages.
2025-02-23 20:08:45 +07:00
Wilfred Hughes 5f5085637e Treat Scheme as a lisp when handling sliders 2024-03-06 21:55:31 +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 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 41c9165c79 Use my line_numbers crate for newline position calculations 2023-08-26 16:25:32 +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
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 045d6a2c58 Treat Newick and Racket as lisps 2023-03-03 00:23:11 +07:00
Wilfred Hughes 998c9e94ff Fix crash on repeated, partially novel lists
Fixes #469
2023-01-25 23:54:41 +07:00
Wilfred Hughes 12fe91560c Add doc comments to slider functions 2023-01-25 23:17:42 +07:00
Wilfred Hughes 9bdd1964b0 Improve doc comments 2023-01-23 08:47:52 +07:00
Wilfred Hughes 6c3dc6b69e Fix formatting in comment 2023-01-23 08:38:40 +07:00
Wilfred Hughes 94b6117723 Define an --ignore-comments option and pass to parser
Initial work for #449
2023-01-10 08:47:58 +07:00
Wilfred Hughes 3c51f58d8e Add Pascal support
Fixes #365
2022-09-13 00:05:23 +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 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 8860fabf19 Fix novel_regions_after_unchanged to always append the last region
This is the correct thing to do (and consistent with
novel_regions_before_unchanged), although I haven't found any examples
where it affects the results.
2022-09-02 16:39:11 +07:00
Wilfred Hughes 659f2dd6bd Add support for Makefiles 2022-08-28 16:26:01 +07:00
Wilfred Hughes 2cc05f340f rustfmt 2022-08-21 16:01:51 +07:00
Wilfred Hughes bbdc324b7f Add CMake support
Fixes #333
2022-08-20 18:32:32 +07:00
Wilfred Hughes 8547987830 Add Hacklang support 2022-07-11 22:13:37 +07:00
Wilfred Hughes f2ca7cf314 Add SQL support
Closes #311
2022-07-11 09:31:34 +07:00
Wilfred Hughes 970fd7f9d3 Add Julia support
Fixes #284
2022-07-04 15:50:28 +07:00
Wilfred Hughes d72251f9fa cargo fmt 2022-07-04 15:11:38 +07:00
Benjamin Manns d131ae1d35 Add HTML parser 2022-07-01 12:23:20 +07:00
Wilfred Hughes ed168635c9 Use 32-bit integers for line numbers
This saves 16% time, 18% memory and 1% instruction counts from the
sample files in #293. These are large files, treated as textual diffs,
so reducing the storage per-line is significant. Files with structural
diffing, such as sample_files/slow_before.rs, are unchanged.

Fixes #293
Closes #297
2022-06-13 21:47:19 +07:00
Wilfred Hughes 5d5eaea84e Store column numbers as a u32
It's reasonable to assume that a single column won't exceed four
billion, and this is a small speedup (1% instruction count reduction
on the sample file in #293).
2022-06-13 21:26:02 +07:00
Wilfred Hughes f028b46003 cargo fmt 2022-05-25 09:35:28 +07:00
Wilfred Hughes d4285bed7c Move more files into diff/ 2022-05-25 09:31:12 +07:00
Wilfred Hughes c5fe152f25 Define a parse submodule 2022-05-25 09:28:12 +07:00
Wilfred Hughes 373d7d9d81 Define a diff submodule 2022-05-24 09:33:47 +07:00