Commit Graph

11440 Commits (34967f588dd34de0555fa49d91fce0c138b4eeca)
 

Author SHA1 Message Date
Wilfred Hughes 34967f588d Treat predefined_type as an atom in TypeScript
Currently it contains a nested string node, even though it's a fixed
set of known types. This was preventing us from applying good syntax
highlighting.

This was particularly noticeable with `string`, which wasn't
previously highlighted as a type.
2023-01-07 22:43:50 +07:00
Wilfred Hughes 610a6e441d Ensure that textual fallback diffing has a parse language of None
Previously we still passed the parse language after exceeding the
graph limit, leading to incorrect underline highlighting.
2023-01-06 19:07:05 +07:00
Wilfred Hughes 8a799af0ff cargo fmt 2023-01-06 18:18:37 +07:00
Wilfred Hughes 9ae4eb17fd Add test for is_all_whitespace 2023-01-06 18:16:01 +07:00
Wilfred Hughes d8d4b8c003 Add is_all_whitespace helper function 2023-01-06 08:36:54 +07:00
Wilfred Hughes cd87796552 Treat doctype nodes as atoms in HTML
The tree-sitter parser doesn't include the text after DOCTYPE in the
inner tag.
2023-01-03 08:40:39 +07:00
Steinar H. Gunderson 9133918dd4 Support parsing of sub-languages.
This allows given nodes (configurable per-language, using tree-sitter's
query syntax) to be re-parsed as other languages. The canonical example
is CSS or JavaScript inside HTML, which normally would be a single token
but now can get the full range of syntax highlighting and tree diffing.

The config sets this up for only two languages: HTML (contains CSS or
JavaScript in <script> or <style> tags; we don't support style="" or
onclick="" etc. at this point), and Makefiles (contains Bash in
$(shell ...) commands). The latter is fairly obscure; the big win is
in the former.

It would be nice to also have this support for PHP; however, the HTML
parser seems to be a bit confused when asked to parse the partial HTML
blocks we get if we just mark the "text" blocks as HTML, so for this
to work well, probably the PHP blocks should be parsed as sub-languages
of HTML instead of vice versa.

Also, as a minor quibble, there should be support for bash in Perl's
backticks (similar to in Makefiles), but the tree-sitter Perl parser
does not support backticks at all (it goes into error recovery).

There may have been languages that I've missed, e.g. some languages
might have nodes that contain e.g. SQL.

Fixes #382. Potentially relevant to #376.
2023-01-03 08:31:48 +07:00
Wilfred Hughes 0fc1842595 Improve word highlighting heuristics in comments
Previously we highlighted changed whitespace, which led to ugly
results if the number of words changed (there was a different number
of whitespace characters so some were highlighted).

Also treat _ and - as word constituents, as it produces nicer results
when people write example CLI invocations in comments.
2023-01-02 16:56:31 +07:00
Wilfred Hughes 87dcfd2cca Replace tabs in inline output too 2023-01-01 22:55:48 +07:00
Wilfred Hughes e9eb4cd209 Always return the padding amount in split_string_by_width 2023-01-01 22:50:38 +07:00
Wilfred Hughes e8e5ca8e47 Replace tabs during display, so parsing sees the original source
Fixes #350
2023-01-01 22:44:47 +07:00
Wilfred Hughes 7e560ec943 Use .link_lib_modifier() from latest cc version
https://github.com/rust-lang/cc-rs/pull/671 has now been merged and
released, so a247218811 is now unncessary.
2022-12-30 23:13:46 +07:00
Wilfred Hughes 23ef083412 clippy errors should never stop compilation
Workaround suggested in
https://github.com/rust-lang/rust-clippy/issues/9534
2022-12-30 23:13:17 +07:00
Wilfred Hughes 2b00d9fb34 Update bumpalo 2022-12-30 11:35:17 +07:00
Wilfred Hughes 167217052e Update rayon 2022-12-30 10:37:48 +07:00
Wilfred Hughes 08c1a763f2 Basic changelog parsing script for releases 2022-12-28 15:25:42 +07:00
Wilfred Hughes 3c95b2ebbb Roll version 2022-12-28 15:12:58 +07:00
Wilfred Hughes 00ecf36a22 Pop delimiters immediately, rather than having ExitDelimiter* edges
@QuarticCat observed that popping delimiters is unnecessary, and saw a
speedup in PR #401. This reduces the number of nodes in typical graphs
by ~20%, reducing runtime and memory usage.

This works because there is only one thing we can do at the end of a
list: pop the delimiter. The syntax node on the other side does not
give us more options, we have at most one. Popping all the delimiters
as soon as possible is equivalent, and produces the same graph route.

This change has also slightly changed the output of
samples_files/slow_after.rs, producing a better (more minimal)
diff. This is probably luck, due to the path-dependent nature of the
route solving logic, but it's a positive sign.

A huge thanks to @QuarticCat for their contributions, this is a huge
speedup.

Co-authored-by: QuarticCat <QuarticCat@pm.me>
2022-12-28 02:00:09 +07:00
Wilfred Hughes 4bfdc7685c Log vertex count at the info level
This is less noisy and more useful than the path logging at the debug
level.
2022-12-28 01:00:10 +07:00
Wilfred Hughes 57d1f6d449 Reserve the vec inside allocate_if_new
Pushing to this vec was showing 2.5% of total compute time in profiles.
2022-12-28 00:30:25 +07:00
Wilfred Hughes 9745d06c87 Add docs for our stack implementation 2022-12-24 17:12:58 +07:00
Wilfred Hughes 3b37b9a12c Expand symlinks before computing relative path for display paths
Fixes #447
2022-12-22 22:48:27 +07:00
Wilfred Hughes d18acce856 Update changelog for 08e7b5f41 2022-12-22 09:17:19 +07:00
Wilfred Hughes a2fa9fdbf5 Update changelog for fda897b81 2022-12-22 09:14:28 +07:00
Wilfred Hughes 3766b944a8 Define a struct for DiffOptions 2022-12-22 09:11:59 +07:00
Wilfred Hughes 08e7b5f413 Use Ubuntu 20.04 for builds
ubuntu-latest now points to 22.04:
https://github.blog/changelog/2022-11-09-github-actions-ubuntu-latest-workflows-will-use-ubuntu-22-04/

This means that distros witih older glibc versions can't use the 0.39
binaries attached to the release. The next release should resolve
this (see #446).
2022-12-21 22:33:45 +07:00
Wilfred Hughes cadceb20b0 Show whole file names too with --list-languages 2022-12-19 09:33:53 +07:00
Wilfred Hughes a21327ab13 Factor out a constant for language file associations 2022-12-19 09:23:46 +07:00
Wilfred Hughes fda897b816 Don't parse rebar.lock files as Erlang
The Erlang parser doesn't support this syntax apparently:
https://github.com/WhatsApp/tree-sitter-erlang/issues/3
2022-12-19 01:00:56 +07:00
Wilfred Hughes d169c7f96c Update version in Cargo.lock 2022-12-19 01:00:48 +07:00
Wilfred Hughes 723e3dbd0e Roll version 2022-12-19 00:20:42 +07:00
Wilfred Hughes e0fcf2b84b Add a --check-only flag
Fixes #386
2022-12-18 23:55:22 +07:00
Wilfred Hughes abd5e07654 Add a has_syntactic_changes field 2022-12-18 23:21:36 +07:00
Wilfred Hughes b34cdabfdc Prefer has_changes to has_same for clarity 2022-12-18 23:17:05 +07:00
Wilfred Hughes a2f22cb17c Only set the exit code if --exit-code is set
This is important for usage with git log, which terminates on non-zero
exit codes.
2022-12-18 23:11:18 +07:00
Wilfred Hughes b7cfff3f27 Silence some clippy lints 2022-12-18 00:33:27 +07:00
Wilfred Hughes 6a46237bb0 Set the exit code when changes are found
Closes #285
2022-12-18 00:28:54 +07:00
Wilfred Hughes 7dd6bbd609 Implement Default on DisplayOptions 2022-12-17 23:49:18 +07:00
Wilfred Hughes aa067e636b Don't bother storing bytes of binary files 2022-12-17 23:44:48 +07:00
Wilfred Hughes 4b2e601de1 Store hunks in Summary 2022-12-17 23:42:20 +07:00
Wilfred Hughes 2cf27ec7cd Display paths relative to cwd
Fixes #444
2022-12-16 10:08:38 +07:00
Wilfred Hughes afc78e976d Document Erlang support and add test
Fixes #394
2022-12-15 23:30:45 +07:00
Wilfred Hughes bb2ae868d7 Add basic Erlang syntax highlighting
Improves #394
2022-12-15 23:20:37 +07:00
Wilfred Hughes 583c55964b Fix typo 2022-12-15 09:27:13 +07:00
Wilfred Hughes 75299f79fd Configure erlang delimiters 2022-12-14 23:58:15 +07:00
Wilfred Hughes e6cec41e23 Add basic Erlang support
Add tree-sitter and configure language detection. Helps with #394

Co-authored-by: Benedikt Reinartz <filmor@gmail.com>
2022-12-14 23:51:26 +07:00
Wilfred Hughes db3a1db04e Add 'vendor/tree-sitter-erlang/' from commit 'a8b8b0e16c4f5552f5e85af3dec976a5d16af8b9'
git-subtree-dir: vendor/tree-sitter-erlang
git-subtree-mainline: c5985c88b2
git-subtree-split: a8b8b0e16c
2022-12-14 23:35:23 +07:00
Wilfred Hughes c5985c88b2 Allow null bytes in UTF16 input files 2022-12-13 09:38:24 +07:00
Wilfred Hughes 7b31be8adb Improve binary file detection heuristics
Fixes #433
2022-12-08 10:29:35 +07:00
Wilfred Hughes 84a968cdbb cargo fmt 2022-12-08 10:28:24 +07:00