Skip to content

feat: make diff tab width configurable#588

Merged
benvinegar merged 1 commit into
mainfrom
feat/configurable-tab-width
Jul 24, 2026
Merged

feat: make diff tab width configurable#588
benvinegar merged 1 commit into
mainfrom
feat/configurable-tab-width

Conversation

@benvinegar

Copy link
Copy Markdown
Member

Summary

  • expand tabs at real terminal-cell tab stops with a new default width of 4
  • add tab_width config plus -x / --tab-width CLI overrides
  • propagate tab width through interactive rendering, geometry and width caches, static pager output, and OpenTUI components
  • document the setting and add unit, component, static-pager, and live PTY coverage

Closes #551.

Testing

  • bun run typecheck
  • bun run lint
  • bun run format:check
  • focused unit/component suite: 214 passed
  • bun test test/pty/layout.test.ts: 13 passed
  • bun run test:tty-smoke: 9 passed
  • bun run build:bin
  • real PTY smoke test with a tabbed diff
  • bun run test:integration: 55 passed; the direct-file atomic-save watch test timed out identically on a clean origin/main worktree

This PR description was generated by Pi using GPT-5.6

@greptile-apps

greptile-apps Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Adds configurable terminal-cell tab stops throughout Hunk.

  • Adds validated tab_width configuration and -x / --tab-width CLI overrides, defaulting to 4 columns.
  • Propagates tab width through interactive rendering, geometry caches, collapsed rows, static pager output, and public OpenTUI components.
  • Expands tabs according to terminal display width and syntax-highlight span position.
  • Documents the new option and adds CLI, configuration, rendering, component, pager, and PTY coverage.

Confidence Score: 5/5

The PR appears safe to merge, with tab width consistently validated and propagated across the affected rendering paths.

Tab expansion uses terminal-cell measurements, highlighted spans preserve their cumulative display column, and tab width participates in shared row planning and geometry cache invalidation; the changed paths also include focused coverage.

Important Files Changed

Filename Overview
src/core/tabWidth.ts Centralizes the default, bounded runtime validation, and strict CLI parsing for tab widths.
src/core/config.ts Reads, validates, layers, and defaults the new tab_width configuration.
src/core/cli.ts Adds the short and long CLI overrides and carries the parsed value into common options.
src/ui/diff/codeColumns.ts Expands source tabs at terminal-cell-aware tab stops rather than replacing each tab with a fixed number of spaces.
src/ui/diff/pierre.ts Applies tab expansion consistently to plain and syntax-highlighted rows while preserving columns across highlight spans.
src/ui/diff/diffSectionGeometry.ts Includes tab width in row planning and geometry cache identity, preventing stale measurements across widths.
src/ui/staticDiffPager.ts Applies the resolved tab width to the non-interactive pager rendering path.
src/opentui/HunkDiffBody.tsx Exposes the configurable width to embeddable rendering and defaults it consistently with the CLI application.
src/ui/App.tsx Propagates the bootstrap tab width into line-width calculations and the interactive diff pane.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  CLI["CLI -x / --tab-width"] --> Config["Config resolution"]
  TOML["tab_width in TOML"] --> Config
  Config --> Bootstrap["App bootstrap"]
  Bootstrap --> Interactive["Interactive diff renderer"]
  Bootstrap --> Pager["Static diff pager"]
  Public["OpenTUI tabWidth prop"] --> Components["Embeddable components"]
  Interactive --> Rows["Tab-expanded diff rows"]
  Pager --> Rows
  Components --> Rows
  Rows --> Geometry["Width, wrapping, and geometry caches"]
Loading

Reviews (1): Last reviewed commit: "feat: make diff tab width configurable" | Re-trigger Greptile

@benvinegar
benvinegar merged commit 928f607 into main Jul 24, 2026
9 checks passed
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.

Tab size is hard coded to 2

1 participant