Merge branch 'Wilfred:master' into master

pull/511/head
grunweg 2023-05-05 13:43:54 +07:00 committed by GitHub
commit 78d6c163ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 79 additions and 33 deletions

42
Cargo.lock generated

@ -4,22 +4,13 @@ version = 3
[[package]]
name = "aho-corasick"
version = "0.7.18"
version = "0.7.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e37cfd5e7657ada45f742d6e99ca5788580b5c529dc78faf11ece6dc702656f"
checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac"
dependencies = [
"memchr",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d52a9bb7ec0cf484c551830a7ce27bd20d67eac647e1befb56b0be4ee39a55d2"
dependencies = [
"winapi",
]
[[package]]
name = "assert_cmd"
version = "2.0.5"
@ -493,9 +484,9 @@ dependencies = [
[[package]]
name = "owo-colors"
version = "3.4.0"
version = "3.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "decf7381921fea4dcb2549c5667eda59b3ec297ab7e2b5fc33eac69d2e7da87b"
checksum = "c1b04fb49957986fdce4d6ee7a65027d55d4b6d2265e5848bbb507b58ccfdb6f"
[[package]]
name = "parking_lot"
@ -562,14 +553,14 @@ dependencies = [
[[package]]
name = "pretty_assertions"
version = "1.2.1"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c89f989ac94207d048d92db058e4f6ec7342b0971fc58d1271ca148b799b3563"
checksum = "a25e9bcb20aa780fd0bb16b72403a9064d6b3f22f026946029acb941a50af755"
dependencies = [
"ansi_term",
"ctor",
"diff",
"output_vt100",
"yansi",
]
[[package]]
@ -645,9 +636,9 @@ dependencies = [
[[package]]
name = "regex"
version = "1.5.6"
version = "1.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d83f127d94bdbcda4c8cc2e50f6f84f4b611f69c902699ca385a39c3a75f9ff1"
checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d"
dependencies = [
"aho-corasick",
"memchr",
@ -662,9 +653,9 @@ checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "regex-syntax"
version = "0.6.26"
version = "0.6.29"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "49b3de9ec5dc0a3417da371aab17d729997c15010e7fd24ff707773a33bddb64"
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
[[package]]
name = "rustc-hash"
@ -838,12 +829,11 @@ dependencies = [
[[package]]
name = "walkdir"
version = "2.3.2"
version = "2.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56"
checksum = "36df944cda56c7d8d8b7496af378e6b16de9284591917d307c9b4d313c44e698"
dependencies = [
"same-file",
"winapi",
"winapi-util",
]
@ -946,3 +936,9 @@ name = "wu-diff"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e3e6735fcde06432870db8dc9d7e3ab1b93727c14eaef329969426299f28893"
[[package]]
name = "yansi"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"

@ -28,7 +28,8 @@ pkg-url = "{ repo }/releases/download/{ version }/difft-{ target }.{ archive-for
pkg-fmt = "zip"
[dependencies]
regex = "1.5.4"
# This is the last version that supports rust 1.57, regex 1.8 requires rust 1.60.
regex = ">= 1.7, < 1.8"
clap = { version = "3.1.8", features = ["cargo", "env", "wrap_help"] }
itertools = "0.10.1"
typed-arena = "2.0.1"
@ -44,12 +45,14 @@ mimalloc = { version = "0.1.28", default-features = false }
# large textual files, as discussed in #297.
libmimalloc-sys = "=0.1.24"
radix-heap = "0.4.2"
walkdir = "2.3.2"
walkdir = "2.3.3"
const_format = "0.2.22"
owo-colors = "3.3.0"
owo-colors = "3.5.0"
wu-diff = "0.1.2"
# rayon 1.7 requires rust 1.59
rayon = "1.6.1"
tree_magic_mini = "3.0.2"
# bumpalo 3.12 requires newer rust
bumpalo = "3.11.1"
unicode-width = "0.1.9"
crossterm = { version = "0.25.0", features = [] }
@ -61,11 +64,11 @@ assert_cmd = ">= 2, <= 2.0.5"
# last version that supports rustc 1.57.
predicates = ">= 2, <= 2.1.1"
pretty_assertions = "1.2.1"
pretty_assertions = "1.3.0"
[build-dependencies]
cc = "1.0.78"
rayon = "1.5.2"
rayon = "1.6.1"
version_check = "0.9.4"
[profile.release]

@ -10,8 +10,8 @@ your `.hgrc`.
extdiff =
```
You can then run `hg extdiff -p difft` (assumes the `difft` binary is
on your `$PATH`).
You can then run `hg extdiff -p difft` instead of `hg diff`
(assumes the `difft` binary is on your `$PATH`).
You can also define an alias to run difftastic with hg. Add the
following to your `.hgrc` to run difftastic with `hg dft`.
@ -19,9 +19,14 @@ following to your `.hgrc` to run difftastic with `hg dft`.
```
[extdiff]
cmd.dft = difft
opts.dft = --missing-as-empty
# You can add further options which will be passed to the command line, e.g.
# opts.dft = --background light
```
All options of `hg diff` are also supported by `hg dft`; for example,
`hg dft --stat` will show statistics of changed lines and `hg dft -r 42 -r 45`
will show the diff between two revisions.
## hg log -p
Mercurial does not have a way of changing the default diff tool, at

@ -30,7 +30,7 @@ impl LineNumber {
impl fmt::Debug for LineNumber {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_fmt(format_args!(
"LineNumber: {} (raw: {})",
"LineNumber: {} (zero-indexed: {})",
self.one_indexed(),
self.0
))

@ -240,7 +240,7 @@ impl<'a> Syntax<'a> {
pub fn new_atom(
arena: &'a Arena<Syntax<'a>>,
position: Vec<SingleLineSpan>,
mut position: Vec<SingleLineSpan>,
mut content: &str,
kind: AtomKind,
) -> &'a Syntax<'a> {
@ -250,6 +250,11 @@ impl<'a> Syntax<'a> {
content = &content[..content.len() - 1];
}
if kind == AtomKind::Comment && content.ends_with('\n') {
position.pop();
content = &content[..content.len() - 1];
}
arena.alloc(Atom {
info: SyntaxInfo::default(),
position,
@ -1000,6 +1005,43 @@ mod tests {
}
}
#[test]
fn test_new_atom_truncates_trailing_newline() {
let arena = Arena::new();
let position = vec![
SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 8,
},
SingleLineSpan {
line: 1.into(),
start_col: 0,
end_col: 1,
},
];
let content = ";; hello\n";
let atom = Syntax::new_atom(&arena, position, content, AtomKind::Comment);
match atom {
List { .. } => unreachable!(),
Atom {
position, content, ..
} => {
assert_eq!(content, ";; hello");
assert_eq!(
*position,
vec![SingleLineSpan {
line: 0.into(),
start_col: 0,
end_col: 8,
}]
);
}
}
}
/// Ignore the syntax highighting kind when comparing
/// atoms. Sometimes changing delimiter wrapping can change
/// whether a parser thinks that a node is e.g. a type.