Giter Site home page Giter Site logo

Comments (4)

dandavison avatar dandavison commented on May 5, 2024 1

Agreed, this seems like the right solution. For reference, bat has

--tabs <T>                    
    Set the tab width to T spaces. Use a width of 0 to pass tabs through directly

from delta.

ioistired avatar ioistired commented on May 5, 2024

In delta's case, passing tabs through directly is broken (why is that BTW? It works fine in diff-so-fancy.) Until/unless that is fixed, something like 0 should be disallowed.

from delta.

dandavison avatar dandavison commented on May 5, 2024

It works fine in diff-so-fancy.

This is because diff-so-fancy doesn't have background shading extending to the terminal width. In contrast, delta applies a background color and attempts to fill the color rightwards, to the current terminal width. To do this, it needs to know two things:
(1) The width in characters of the pseudo terminal being used by the terminal emulator. This is not a problem; delta uses the console crate for this.
(2) If your terminal renders makes some characters (e.g. tabs) take up more than one character's width on the screen, it needs to take this into account also. It needs to be told this explicitly.

In delta's case, passing tabs through directly is broken. why is that BTW?

It's arguable that it's not broken: it's just that delta assumes that your terminal renders all characters with the same width (including tabs). There's no clean and cross-platform way for a command line application to detect the width that your terminal emulator will use to render tabs that I'm aware of.

Until/unless that is fixed, something like 0 should be disallowed.

Yes, I think I might have disallowed it except for one thing! One of the tests that runs as part of the test suite asserts that the diff output from delta, across the entire repo history, is byte-for-byte identical to the diff output from git without delta. So I need --tabs=0 for that test. In practice, I've found this test helpful for catching several bugs during development. So here, I think a helpful test beats the risk that someone will set it to zero and be confused by the behavior. In #17 I added the following option:

--tabs <tab_width>
    The number of spaces to replace tab characters with. Use --tabs=0 to pass tab characters through directly,
    but note that in that case delta will calculate line widths assuming tabs occupy one character's width on
    the screen: if your terminal renders tabs as more than than one character wide then delta's output will look
    incorrect. [default: 4]

from delta.

ioistired avatar ioistired commented on May 5, 2024

Huh, ok. Is there a way to set always pass through tabs, yet still assume they are tab_width characters wide? It's not a big deal, I just think it would be nice if I could copy from delta while preserving tabs.

from delta.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.