miette/src/handlers
Rebecca Turner 829c4445a1 textwrap: don't split words at punctuation by default
The default `textwrap::WordSeparator::UnicodeBreakProperties` provides
sensible line breaking for (e.g.) emojis and CJK text. Unfortunately, it
also considers punctuation like `/` to be an appropriate location for
line breaks. This is fine for normal text, but leads to very bad
behavior when attempting to wrap error messages. Here, a file path is
broken across multiple lines (with box drawing characters added in
between parts of the path as well), making it impossible to copy-paste
the path out of the error message:

```
Error:   × Failed to read Buck2 event log from `buck2 build //aaa/aaaa` via /var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/
  │ T/.tmpBgvlUI/buck-log.jsonl.gz
  ╰─▶ failed to open file `/var/folders/z5/fclwwdms3r1gq4k4p3pkvvc00000gn/T/.tmpBgvlUI/buck-log.jsonl.gz`: No such
      file or directory (os error 2)
```

In the future, we may want to write our own line break algorithm that
breaks between CJK codepoints and emojis but not at punctuation like
slashes. For now, I believe it will be better to break lines at ASCII
spaces only.

Similar changes are made for some other settings:
- The default for `break_words` has been changed to `false` for similar
  reasons.
- The default `textwrap::WordSplitter` has been changed to not split
  words at existing hyphens, to prevent splits like `--foo-bar` into
  `--foo-` and `bar`.
2025-10-02 17:19:44 -07:00
..
debug.rs fix(ci, clippy): raise MSRV to 1.82, fix rust 1.90 warnings (#451) 2025-09-29 09:43:02 -07:00
graphical.rs textwrap: don't split words at punctuation by default 2025-10-02 17:19:44 -07:00
json.rs fix(ci, clippy): raise MSRV to 1.82, fix rust 1.90 warnings (#451) 2025-09-29 09:43:02 -07:00
mod.rs feat(wasm): add feature "fancy-no-syscall" for wasm targets (#349) 2024-02-23 07:42:39 -08:00
narratable.rs fix(ci, clippy): raise MSRV to 1.82, fix rust 1.90 warnings (#451) 2025-09-29 09:43:02 -07:00
theme.rs fix(color): setting NO_COLOR should not print ansi codes for non-terminals (#381) 2024-06-11 09:18:24 -07:00