delta icon indicating copy to clipboard operation
delta copied to clipboard

🐛 Tabs are displayed incorrectly.

Open Mango0x45 opened this issue 3 years ago • 8 comments

Tabs characters usually function in columns, meaning that if I write Hi\tWorld and Hello\tWorld, both occurances of World should be aligned. In Delta however this alignment doesn't work and instead tabs are always printed as the exact width that they're set to.

This is what my test file looks like in my editor (and how it should look):

This is what delta produces:

Mango0x45 avatar Oct 02 '21 16:10 Mango0x45

Indeed, also see #522.

th1000s avatar Oct 04 '21 19:10 th1000s

I wasn't sure, in my PR, whether this behavior should be configurable. I can't really imagine that people would want the existing behavior, but sometimes my imagination is lacking. 😄

dhduvall avatar Oct 27 '21 17:10 dhduvall

PR #1205 would address that, but is this use case that common?

th1000s avatar Jun 19 '23 22:06 th1000s

It's probably not that common, but I use tabs for alignment.

For example in shell scripts (using spaces in my example, but the part before the \s would be tabs):

command           \
    --option-a    \
    --other-opt   \
    -x yz         \

Why align? makes it easier to see the command since it appears as a block. Why tabs? less work to get them to align then spaces.

andy29485 avatar Jul 20 '23 12:07 andy29485

Same problem here. I thought delta would be a really good tool to review new code. But as it turns out, it fails at even the simplest task. If I would for example perform a:

git log -p -- include/uapi/asm-generic/errno-base.h

The changes I would see are:

#ifndef _ASM_GENERIC_ERRNO_BASE_H
#define _ASM_GENERIC_ERRNO_BASE_H

#define        EPERM                 1        /* Operation not permitted */
#define        ENOENT                 2        /* No such file or directory */
#define        ESRCH                 3        /* No such process */
#define        EINTR                 4        /* Interrupted system call */
#define        EIO                 5        /* I/O error */
#define        ENXIO                 6        /* No such device or address */
#define        E2BIG                 7        /* Argument list too long */
#define        ENOEXEC                 8        /* Exec format error */
#define        EBADF                 9        /* Bad file number */
#define        ECHILD                10        /* No child processes */
#define        EAGAIN                11        /* Try again */
#define        ENOMEM                12        /* Out of memory */
#define        EACCES                13        /* Permission denied */
#define        EFAULT                14        /* Bad address */
#define        ENOTBLK                15        /* Block device required */
#define        EBUSY                16        /* Device or resource busy */
#define        EEXIST                17        /* File exists */
#define        EXDEV                18        /* Cross-device link */
#define        ENODEV                19        /* No such device */
#define        ENOTDIR                20        /* Not a directory */
#define        EISDIR                21        /* Is a directory */
#define        EINVAL                22        /* Invalid argument */
#define        ENFILE                23        /* File table overflow */
#define        EMFILE                24        /* Too many open files */
#define        ENOTTY                25        /* Not a typewriter */
#define        ETXTBSY                26        /* Text file busy */
#define        EFBIG                27        /* File too large */
#define        ENOSPC                28        /* No space left on device */
#define        ESPIPE                29        /* Illegal seek */
#define        EROFS                30        /* Read-only file system */
#define        EMLINK                31        /* Too many links */
#define        EPIPE                32        /* Broken pipe */
#define        EDOM                33        /* Math argument out of domain of func */
#define        ERANGE                34        /* Math result not representable */

#endif

Then I would have replied to the author that he is drunk and first sober up before submitting code again. But when looking at the actual code, it would have been clear that the author was sober but delta is drunk.

The only way to use delta (in this context) is to disable most of its functionalities:

 [core]
-        pager = delta
+[pager]
+        diff = delta --color-only | /usr/bin/less -x1,9
+        log = delta --color-only | /usr/bin/less -x1,9
+        show = delta --color-only

But this is far from perfect

CharlemagneLasse avatar Feb 17 '24 18:02 CharlemagneLasse

PR https://github.com/dandavison/delta/pull/1205 would address that, but is this use case that common?

Ever heard of this niche code base called Linux? Or the source code of this unavowed SCM called git? Or this thing called GCC, glibc, GCC, gimp, inkscape, firefox, ...

And even if it is only part of a test, you can find such a tab in delta src/handlers/diff_header.rs or src/subcommands/list_syntax_themes.rs. Or (not a test) in etc/completion/completion.fish

CharlemagneLasse avatar Feb 17 '24 19:02 CharlemagneLasse

Ever heard of this niche code base called Linux?

@CharlemagneLasse the person you are replying to is the author of https://github.com/dandavison/delta/pull/1205. If we build delta on his branch, and clone the linux kernel, we find

git log -p -- include/uapi/asm-generic/errno-base.h
image

It seems impolitic, to say the least, to speak like that to the author of the PR which is fixing the issue that you are (rightly) saying should be fixed!

Would you like to fix the (few) merge conflicts on https://github.com/dandavison/delta/pull/1205 so that we can get it merged and released?

dandavison avatar Feb 17 '24 19:02 dandavison

PR #1205 would address that, but is this use case that common?

Well I opened this issue 3 years ago and I can confidently say that this functionality has only become even more important in that time for me

Mango0x45 avatar Feb 18 '24 15:02 Mango0x45