`ansi` command should not output ANSI color codes when `use_ansi_coloring` is disabled in config
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Describe the bug
This is the root cause of #14043.
In (unrelated to 14043) digging around in the ansi command, it comes to mind that the reason why user-land ANSI was still coloring output in #14043 is that the ansi command itself still outputs color codes, even when use_ansi_coloring is false.
This shouldn't happen.
The ansi command actually checks the use_ansi_coloring option, but only to determine if color previews should be shown with ansi --list/-l. It should also check before outputting a color (or attribute) code.
How to reproduce
Note: to reproduce correctly, each line of the following must be executed separately; otherwise the environment won't be re-read before the command is executed ...
$env.use_ansi_coloring = false
$"(ansi red)This shouldn't be Red, but it is(ansi reset)"
Expected behavior
I expect the ansi command to disregard color and attribute codes when use_ansi_coloring is false. ANSI codes related to cursor positioning, clearing the screen, and others should still be output.
Configuration
| key | value |
|---|---|
| version | 0.98.1 |
| major | 0 |
| minor | 98 |
| patch | 1 |
| branch | virtual-mods |
| commit_hash | 1dc58b84a85a7d7e8fa4a9fec866582eddcfc036 |
| build_os | linux-x86_64 |
| build_target | x86_64-unknown-linux-gnu |
| rust_version | rustc 1.79.0 (129f3b996 2024-06-10) |
| rust_channel | 1.79.0-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.79.0 (ffa9cf99a 2024-06-03) |
| build_time | 2024-10-09 13:39:29 -04:00 |
| build_rust_channel | release |
| allocator | mimalloc |
| features | default, sqlite, trash |
| installed_plugins |
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ansi command implementation and its existing use_ansi_coloring check, which currently only affects ansi --list/-l. Verify the reproduction with $env.use_ansi_coloring = false; done means color and attribute codes are suppressed while cursor-positioning and screen-clearing codes still output.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100