TUI: wrap long diff lines (markdown diffs get cut off)

Open
#16,997 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
76/100
Issue type
Feature
Clarity
Clearly specified
Activity status
Active
Tech stack
rust
Domain
cli, frontend

Research direction

Start with crates/but/src/command/legacy/status/tui/details.rs and trace how DetailsLine::Code rows are rendered and counted against the details pane width. Compare that with the existing TextToWrap handling and the GUI’s diff::ToggleWrap behavior. Done when long diff lines can wrap to the available terminal or pane width in the TUI, with a toggle or setting to control wrapping.

Written by the indexing model from the issue text.

Description

I've been using but tui on this device, and one of the issues I'm having is that on markdown files the diffs don't get wrapped. Long lines just get cut off at the edge of the details pane, so for markdown (where a whole paragraph is one line) you basically can't read the change unless you open the GUI.

The GUI has the ability to (soft)wrap text (alt-z / diff::ToggleWrap), so it would be great to have the same thing in the TUI.

what I'd like

  • a way to wrap diff lines based on the terminal / pane width
  • either a keybinding toggle like the GUI, or a setting (but config ... or an env var like BUT_THEME) so it can be on by default

what I checked

  • but tui --help and but config don't have any wrap option
  • the TUI docs (https://docs.gitbutler.com/gitbutler-tui) don't mention wrapping
  • looking at the source, crates/but/src/command/legacy/status/tui/details.rs only wraps TextToWrap (commit messages). DetailsLine::Code lines are rendered into a single row and always counted as 1 line, so anything past the width gets clipped

workarounds right now

  • but diff --no-tui (terminal wraps it)
  • git diff --word-diff

both work but you lose the TUI flow, so a toggle in the TUI would be really nice.

version

but 0.23.2 on macOS

Dominant language
Rust
Stars
21.9k
Forks
1k
Avg merge
6h 1m
Merged PRs (30d)
657

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from gitbutlerapp/gitbutler

All issues in gitbutlerapp/gitbutler

Similar issues

More Rust issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.