Skip to content

Tabs are never expanded, so tab-indented files render flush left #1

Description

@fatbrother

What happens

In a repository that indents with tabs, every line in the diff pane is drawn
starting at column 0.

Might like below

test: function(taskState)
{
aaaaa
vvvv

bbbb
if () 
{
}
},

Why

ratatui draws into a cell grid and does not interpret \t; the terminal never
sees the character either, so nothing expands it. gitview does not expand it
first — the only \t handling in the tree is field splitting:

src/git.rs:801              field.split('\t')       # git output columns
src/preview/session.rs:289  answer.split_once('\t') # pane picker reply

render::build hands old / new straight to Highlighter::highlight and
TextDiff::from_lines, so the raw tab survives into the Run text and is
dropped at draw time.

Reproduce

Just open any file with some indent with gitview.

Suggested fix

A width knob is worth having (tab_width, default 4 or 8) since it is per
project taste, and the expansion can be skipped entirely when neither side
contains a tab, so nothing is allocated for the common case.

I have a patch along these lines if it would be useful — it adds tab_width to
Config (clamped) and an expand_tabs helper applied at the top of build.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions