Compare commits

...

2 Commits

Author SHA1 Message Date
Wilfred Hughes 683dbe5a1b Minor markdown fixes 2025-11-10 22:49:29 +07:00
Wilfred Hughes dd18b1d6cd Tweak variable name for MatchedPos values 2025-11-10 22:23:09 +07:00
6 changed files with 24 additions and 20 deletions

@ -49,7 +49,6 @@ From the start vertex, we have two options:
+---------------------+ +---------------------+
```
Choosing "novel atom R" to vertex 2 will turn out to be the best
choice. From vertex 2, we can see three routes to the end vertex.

@ -4,8 +4,12 @@ Difftastic can be installed as pre-built binaries or using various package manag
## Pre-Built Binaries
Difftastic releases are published as [GitHub releases](https://github.com/Wilfred/difftastic/releases) with pre-built binaries for Windows, macOS and Linux.
Open the [latest release page](https://github.com/Wilfred/difftastic/releases/latest), download the file matching your OS and CPU architecture, and extract the `difft` executable application file.
Difftastic releases are published as [GitHub
releases](https://github.com/Wilfred/difftastic/releases) with
pre-built binaries for Windows, macOS and Linux. Open the [latest
release page](https://github.com/Wilfred/difftastic/releases/latest),
download the file matching your OS and CPU architecture, and extract
the `difft` executable application file.
## Package Manager
@ -36,7 +40,9 @@ with `nix-env`.
$ nix-env --install difftastic
```
If you're a **Fedora** user, you can install [difftastic](https://packages.fedoraproject.org/pkgs/rust-difftastic/difftastic/) with `dnf`.
If you're a **Fedora** user, you can install
[difftastic](https://packages.fedoraproject.org/pkgs/rust-difftastic/difftastic/)
with `dnf`.
```
$ sudo dnf install difftastic
@ -52,7 +58,8 @@ $ sudo pkg install difftastic
### Windows
If you're a Windows user using **Windows Package Manager** (*WinGet*), you can install difftastic with `winget`.
If you're a Windows user using **Windows Package Manager** (*WinGet*),
you can install difftastic with `winget`.
```
$ winget install difftastic

@ -11,5 +11,3 @@ file](https://jj-vcs.github.io/jj/latest/config/#user-config-files).
[ui]
diff-formatter = ["difft", "--color=always", "$left", "$right"]
```

@ -27,7 +27,7 @@ $ ln -s tree-sitter-json/src tree-sitter-json-src
```
You can now add the parser to build by including the directory in
`build.rs`.
`build.rs`.
```
TreeSitterParser {

@ -17,8 +17,8 @@ pub(crate) fn print(
lhs_src: &str,
rhs_src: &str,
display_options: &DisplayOptions,
lhs_positions: &[MatchedPos],
rhs_positions: &[MatchedPos],
lhs_mps: &[MatchedPos],
rhs_mps: &[MatchedPos],
hunks: &[Hunk],
display_path: &str,
extra_info: &Option<String>,
@ -32,7 +32,7 @@ pub(crate) fn print(
display_options.syntax_highlight,
file_format,
display_options.background_color,
lhs_positions,
lhs_mps,
),
apply_colors(
rhs_src,
@ -40,7 +40,7 @@ pub(crate) fn print(
display_options.syntax_highlight,
file_format,
display_options.background_color,
rhs_positions,
rhs_mps,
),
)
} else {
@ -63,8 +63,8 @@ pub(crate) fn print(
.map(|line| style::replace_tabs(&line, display_options.tab_width))
.collect();
let opposite_to_lhs = opposite_positions(lhs_positions);
let opposite_to_rhs = opposite_positions(rhs_positions);
let opposite_to_lhs = opposite_positions(lhs_mps);
let opposite_to_rhs = opposite_positions(rhs_mps);
for (i, hunk) in hunks.iter().enumerate() {
println!(

@ -329,12 +329,12 @@ pub(crate) fn color_positions(
background: BackgroundColor,
syntax_highlight: bool,
file_format: &FileFormat,
positions: &[MatchedPos],
mps: &[MatchedPos],
) -> Vec<(SingleLineSpan, Style)> {
let mut styles = vec![];
for pos in positions {
for mp in mps {
let mut style = Style::new();
match pos.kind {
match mp.kind {
MatchKind::UnchangedToken { highlight, .. } | MatchKind::Ignored { highlight } => {
if syntax_highlight {
if let TokenKind::Atom(atom_kind) = highlight {
@ -400,7 +400,7 @@ pub(crate) fn color_positions(
}
}
};
styles.push((pos.pos, style));
styles.push((mp.pos, style));
}
styles
}
@ -411,9 +411,9 @@ pub(crate) fn apply_colors(
syntax_highlight: bool,
file_format: &FileFormat,
background: BackgroundColor,
positions: &[MatchedPos],
mps: &[MatchedPos],
) -> Vec<String> {
let styles = color_positions(side, background, syntax_highlight, file_format, positions);
let styles = color_positions(side, background, syntax_highlight, file_format, mps);
let lines = split_on_newlines(s).collect::<Vec<_>>();
style_lines(&lines, &styles)
}