Skip to content

feat: add force16Color config option#1337

Open
jojosenthusiast wants to merge 1 commit into
sourcegraph:mainfrom
jojosenthusiast:fix/16-color-config
Open

feat: add force16Color config option#1337
jojosenthusiast wants to merge 1 commit into
sourcegraph:mainfrom
jojosenthusiast:fix/16-color-config

Conversation

@jojosenthusiast

Copy link
Copy Markdown

Closes #1144

Reproduction

src previously either emitted no colours or 256-colour ANSI SGR sequences such as 38;5;N / 48;5;N. Users with terminal themes that make those 256-colour choices hard to read had to disable colour entirely.

Fix summary

  • Add force16Color to ~/src-config.json parsing.
  • Apply the setting in both legacy and migrated command paths.
  • Remap cmd/src and lib/output 256-colour SGR sequences to terminal-theme 16-colour SGR when enabled.
  • Preserve disabled-colour behavior for blanked ansiColors entries.
  • Document the config key in the README.

Tests run

  • go test -count=1 ./cmd/src
  • (cd lib && go test -count=1 ./output)
  • gofmt -l cmd/src/cmd_test.go cmd/src/colors_test.go cmd/src/run_migration_compat_test.go cmd/src/main_test.go cmd/src/colors.go cmd/src/cmd.go cmd/src/main.go cmd/src/run_migration_compat.go lib/output/style.go lib/output/style_test.go lib/output/setup_test.go
  • Judgment Day: two blind reviewers approved after final fixes.
  • Ponytail review: Lean already. Ship.

Risk

Low-to-medium. This touches global CLI colour rendering state, but the default behavior is unchanged unless force16Color is enabled. Regression tests cover config parsing, legacy command dispatch, migrated command dispatch, cmd/src colour remapping, lib/output style remapping, and disabled-colour preservation.

Non-goals

  • No new CLI flag.
  • No perceptual colour-distance algorithm; the remap only guarantees terminal-theme 16-colour SGR instead of 256-colour SGR.
  • No changes to unrelated batch/service behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

No support for 16 colours

1 participant