dandavison / dandavison/delta

🚀 Context-aware line wrapping

Open
#657 4 comments 3 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
32.2k
Forks
572
Avg merge
11m
Merged PRs (30d)
1

Description

### Preface

Once again, `delta` is an AMAZING tool that I use every day, and definitely makes my workflows (lots of diff reviews) much simpler (and better than GitHub / BitBucket / GitLab diff viewers, due to supporting all of Git's options e.g. `-W`).

### Problem Description

One of the issues that arises frequently is that some of our Java and Swift programmers like having lines that are 600 characters long.

Since `delta` uses one of many various pagers, usually some form of `less`, which supports line-wrapping, but this breaks lots of things (like `delta`'s line numbers). Specifying `LESS=... -S ...` allows side-scroll to view the rest of the line, but this is quite tedious.

This becomes a double-whammy when using `delta --side-by-side` as the long lines are simply truncated, especially on the left-hand side (before). Scrolling only reveals more on the right-hand (after) side.

### Feature Request

Ultimately, it would be nice if `delta` had its own option to support wrapping lines in some kind of context-aware manner. "Context-aware" can simply be "wrap lines, and prepend N+4 spaces" where "N" is the number of leading spaces in the original line. There would likely need to be actual "context aware magic" so that the full wrapped line appears to be on the same line number with `delta -n`, but I assume this is achievable.

This would also make `--side-by-side` more useful, if applied to both sides, especially with long lines.

### Pitfalls and Non-Goals

This will still fail in predictable ways when the number of leading whitespace is large, as apparently some people prefer:

```c
if(...) {
if(...) {
if(...) {
if(...) {
if(...) {
// Ad infinitum, until eventually....
main_logic();
} else {
return err;
}
} else {
return err;
}
} else {
return err;
}
} else {
return err2;
}
} else {
return err1;
}
```

Instead of the (IMHO more readable)

```c
if(!...) {
return err1;
}

if(!...) {
return err2;
}

// add infinitum

main_logic();
```

Contributor guide

Open the contributing guide

Research direction

Start by tracing the CLI handling for line wrapping, `--side-by-side`, and `-n`, then compare how the configured pager handles long lines and `LESS=-S`. Done means a documented option wraps long lines with preserved indentation, keeps line numbers coherent, and applies consistently to both sides of side-by-side output.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.