delta
delta copied to clipboard
🚀 Optional line wrapping
Sorry if this is repeated. I didn't find any similar issues.
Currently, when the line length exceeds its column, an arrow indicates that the line continues
I wish we could wrap the line like bat
currently does and keep the diff highlighting.
Bat with line wrapping
I have a similar issue.
My lines are not wrapped at all when not in side-by-side mode, and so they go over where the line numbers would be. It'd be nice if the terminal size could be detected and then accounted for.
I am seeing the same issue as referred by @augustobmoura - pretty much a standard Ubuntu 20.04 installation with the git/delta config:
[delta]
line-numbers = true
side-by-side = true
plus-color = "#012800"
minus-color = "#340001"
syntax-theme = Monokai Extended
delta is of version 0.4.1.
Hi all, thanks for this. I agree implementing line wrapping like bat does would be a nice feature. I don't think I'm going to be able to work on this in the near future so I'd welcome a pull request and am also happy to discuss what the code change might involve.
Some notes: There's a couple of related aspects to this:
- line wrapping respecting the line numbers panel in normal mode
- line wrapping in side-by-side mode, in the left panel and right panel
In normal mode we don't lose content today, it's just that it's not wrapped prettily in line-numbers mode. Personally I have the -S
flag set in less, i.e. it's less -RS
, so that content never wraps in normal mode (I personally find wrapped code very hard to read and prefer to scroll right when necessary).
However in side-by-side mode we currently lose content, because we can't allow the left panel to flow into the right panel's area and I did not attempt to implement line wrapping in the initial implementation of side-by-side because it would have been made the code change significantly more complicated than it already was.
It's maybe worth noting that in side-by-side mode, it is possible to have the panels use up more horizontal space than your terminal window has, by setting --width X
(where X > your terminal width) and using the -S
flag with less, and scroll right when needed.
Perhaps some of this could be helpful in the README.
sometimes I really want an option to truncate the long line. If with less -RS
, the wrapping line symbol looks extremely ugly.
@kevinhwang91 can you give a full example of a diff that you can't display in the way you want, and show the delta settings you're using? Note that we do have max-line-length
now:
--max-line-length <max-line-length>
Truncate lines longer than this. To prevent any truncation, set to zero. Note that syntax-highlighting very
long lines (e.g. minified .js) will be very slow if they are not truncated [default: 512]
@kevinhwang91 can you give a full example of a diff that you can't display in the way you want, and show the delta settings you're using? Note that we do have
max-line-length
now:--max-line-length <max-line-length> Truncate lines longer than this. To prevent any truncation, set to zero. Note that syntax-highlighting very long lines (e.g. minified .js) will be very slow if they are not truncated [default: 512]
It works, could delta adjust its value by the COLUMNS
of the current terminal?
BTW, I found that it excludes the line number. I have no idea to zoom git diff
to my column and truncate any chars long than my column.
This doesn't seem to work in the git config files @kevinhwang91 - but I can achieve it with
git -c "core.pager=delta --max-line-length=$((COLUMNS - 10))" <git-subcommand>
Note that I needed to subtract 10 because the columns for the line numbers seem not to be included in the max-line-length that delta calculates. Depending on your configuration for line-number formatting, this might be a value smaller or greater than 10.
I agree it would be nice if delta could take the current terminal width into account. Besides $COLUMNS
, it can also be queried by $(tput cols)
if that helps.
git -c "core.pager=delta --max-line-length=$((COLUMNS - 10))" <git-subcommand>
Thanks, but I think I'm encountering an issue for delta, @dandavison , it seems that --max-line-length
work as unexpected, here is the screenshot:
I have tried auto line-wrapping algorithm implemented in https://github.com/dandavison/delta/pull/515, it works very well.
But I don't use side-by-side mode, many other users also don't use side-by-side mode.
And there are some modes that can't use side-by-side mode, such as git blame
.
So we need the same auto line-wrapping algorithm as the one in side-by-side when we don't use side-by-side mode.
It maybe can reuse code, and core algorithm has been implemented.
Hope you can add it soon, we really require this feature to display our git diff
and git blame
better!
Thank you!
cc @th1000s, you have implemented line-wrapping in side-by-side mode, Could you please also take a look at the implementation of the line-wrapping algorithm in the non-side-by-side mode? Thanks very much!
Line wrapping by default for some languages like LaTeX would be extremely helpful. I find it quite annoying to do manual linebreaks for natural language paragraphs, where I want all lines to be of similar length (this is very different to source code of course). Line wrapping in text editors does exactly that. For now I'm using pager = delta --wrap-max-lines 16
, but ultimately I'd like lines of any length to be wrapped with .tex
files, but no line wrapping for ugly files like .min.js
or .min.css
.