diff: `-y` draws the gutter marker at the wrong column unless the gutter is 3 or 4 columns wide
Nessuno ha ancora preso questa issue.
- Lingua principale
- Rust
- Stelle
- 276
- Fork
- 39
- Merge medio
- 3h 27m
- PR unite (30g)
- 3
Descrizione
In side-by-side output, Config::separator_pos holds the middle of the gutter, but the gutter marker is not written there. It goes wherever process_half_line stopped padding the left half line, which is one column past sdiff_half_width. separator_pos is only read afterwards, to pad from the marker to the start of column two.
For a gutter g columns wide, separator_pos is sdiff_half_width + (g - 1) / 2. The two positions agree only when g is 3 or 4. The default --width=130 --tabsize=8 produces a gutter of exactly 3, which is why the default output looks correct, but any width or tab size where the tab alignment pushes column two further past the balance point drifts. --width=130 --tabsize=4 is off by one, --width=200 --tabsize=8 by two, --width=130 --tabsize=128 by 61.
printf 'aa\n' > f1; : > f2
diff -y --width=40 f1 f2 | expand | cat -A
aa <$
diffutils diff -y --width=40 f1 f2 | expand | cat -A
aa <$
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Inizia tracciando Config::separator_pos e process_half_line nel percorso di output affiancato per vedere dove viene emesso il marcatore della gutter e dove inizia la seconda colonna. Riproduci il problema con diff -y --width=40 e le combinazioni di larghezza e dimensione del tab descritte, quindi aggiungi una copertura di regressione che mostri che il marcatore è centrato su separator_pos per gutter più ampie.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- rust
- Ambito
- cli
- Tipo di issue
- Bug
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Stato di attività
- Tranquilla
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 68/100