Open
Description
What steps will reproduce the bug?
- Run
touch /tmp/A—B가
, where ‘—’ is a multibyte UTF-8 character and ’가’ is a multibyte double-width CJK character. - Run
bat --terminal-width=30 /tmp/A—B가
.
What happens?
bat
crashes:
thread 'main' panicked at /usr/src/debug/rust/rustc-1.84.0-src/library/core/src/str/mod.rs:648:21:
byte index 21 is not a char boundary; it is inside '가' (bytes 20..23) of `File: /tmp/A—B가 <EMPTY>`
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
───────┬──────────────────────
Different widths give different results:
- with 26 or 27, it crashes with the boundary inside ‘—’;
- with 21 or 22, it doesn’t crash but ANSI colour codes are broken:
146;131;116m│ m <EMPTY>
.
What did you expect to happen instead?
Depending on the width, either not crashing or not breaking ANSI colour codes.
How did you install bat
?
I’m using the latest ArchLinux package.
bat version and environment
Software version
bat 0.25.0 (v0.25.0-modified)
Operating system
Linux 6.13.5-arch1-1
Command-line
bat --diagnostic
Environment variables
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_PAGER=<not set>
BAT_PAGING=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
COLORTERM=truecolor
LANG=en_US.UTF-8
LC_ALL=<not set>
LESS=' --RAW-CONTROL-CHARS --tilde --incsearch --ignore-case --clear-screen '
MANPAGER='nvim +Man'\!''
NO_COLOR=<not set>
PAGER=less
SHELL=/bin/bash
TERM=alacritty
XDG_CACHE_HOME=/home/vejkse/.cache
XDG_CONFIG_HOME=/home/vejkse/.config
System Config file
Could not read contents of '/etc/bat/config': No such file or directory (os error 2).
Config file
--theme=gruvbox-dark
Custom assets metadata
Could not read contents of '/home/vejkse/.cache/bat/metadata.yaml': No such file or directory (os error 2).
Custom assets
'/home/vejkse/.cache/bat' not found
Compile time information
- Profile: release
- Target triple: x86_64-unknown-linux-gnu
- Family: unix
- OS: linux
- Architecture: x86_64
- Pointer width: 64
- Endian: little
- CPU features: fxsr,sse,sse2
- Host: x86_64-unknown-linux-gnu
Less version
> less --version
less 668 (PCRE2 regular expressions)
Copyright (C) 1984-2024 Mark Nudelman
less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: https://greenwoodsoftware.com/less