Closed aarondill closed 1 year ago
I'll look at this more tomorrow, what --version
of eza are you on?
@cafkafk ive compiled eza from source (see got commit in version info, HEAD as of issue creation)
I was able to reproduce this
I'm gonna try to get https://github.com/cafkafk/eza/issues/83 done first, hopefully it will magically solve this.
I think the root cause is here in 'src/output/grid.rs`, where we give the contents as the contents, but the file name as the width, leading to a mismatch with icons enabled.
According to the comment, escapes stop us from using the content's width, so perhaps a workaround would be to just add one if --icons
are enabled (can we always assume an icon will be shown if enabled?)
grid.add(tg::Cell {
contents: contents.strings().to_string(),
// with hyperlink escape sequences,
// the actual *contents.width() is larger than actually needed, so we take only the filename
width: filename.bare_width(),
});
Back in exa v0.10.1, the code looked like this:
grid.add(tg::Cell {
contents: filename.strings().to_string(),
width: *filename.width(),
});
}
Actually, exa's HEAD still uses *filename.width()
, so this is a change made here
Then https://github.com/cafkafk/eza/pull/17/files#diff-0507c61e0f30892ff1a00883c4669b4a13c41e9377ae9bdf8d3818f38506eb63 is the probable culprit I suppose
The blame shows this change being in 8196d52dd352df19543b42350baf9ba53d8733ff. I'm gonna try before this commit to see if I can reproduce the issue
Checking out before doesn't quite work because the grid was still completely messed up before that, but reverting filename.bare_width()
to *contents.width()
does seem to solve the issue (though potentially causes other issues?)
Checking out before doesn't quite work because the grid was still completely messed up before that, but reverting
filename.bare_width()
to*contents.width()
does seem to solve the issue (though potentially causes other issues?)
It would likely break --hyperlinks
?
very much so. Before:
> cargo run --release -- --hyperlink
build.rs Cargo.toml cliff.toml completions file flake.nix Justfile man rust-toolchain.toml snap target Vagrantfile
Cargo.lock CHANGELOG.md CODE_OF_CONDUCT.md devtools flake.lock heloo?h\\ LICENCE README.md screenshots.png src treefmt.nix xtests
After:
> cargo run --release -- --hyperlink
build.rs file rust-toolchain.toml
Cargo.lock flake.lock screenshots.png
Cargo.toml flake.nix snap
CHANGELOG.md heloo?h\\ src
cliff.toml Justfile target
CODE_OF_CONDUCT.md LICENCE treefmt.nix
completions man Vagrantfile
devtools README.md xtests
I think the options here would be:
--icons
status to the function (somehow), and add one if true
Keep track of the length of the file before adding escapes, and add one (/length of the icon) when adding an icon
This might be the preferred solution, but I think it would require a bit of a refactor.
Pass the current --icons status to the function (somehow), and add one if true
I've got something a bit like this in mind (reacting to hyperlink being present in filename.options as well as icons being present there). Perhaps this is the short term solution to go for first. I've got a sketch for a solution for this, I'll create a PR for it in a moment.
I think I got this working now
Here's a reproduction: Note that the line splitting is put in place by me. It is technically outputting a single line, but because it reaches the end, it wraps. When copying the output, I had to manually insert newlines to mimic the output seen on my terminal.
Versioning
Git commit: 5f29705cc5e8b98b94876a6c679eaef1d1d81028 ```shell > cat /etc/os-release PRETTY_NAME="Ubuntu 22.04.2 LTS" NAME="Ubuntu" VERSION_ID="22.04" VERSION="22.04.2 LTS (Jammy Jellyfish)" VERSION_CODENAME=jammy ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=jammy > rustc --version rustc 1.73.0-nightly (db7ff98a7 2023-07-31) ```Does this have something to do with #66 / #83?
Note: the same procedure with
exa v0.10.1 [-git]
: