Comments (4)
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.
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.
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.
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)
- Navigate keybinds only go between hunks, not files
- update intsructions for tmux color issues
- 🐛 Online user manual website not working HOT 4
- 🐛 When piping --help, the output should not contain escape chars
- 🐛 `--color-only` doesn't produce any colour HOT 2
- 🚀 diff chinese words better HOT 2
- 🐛 Highlighting of capitalisation changes does not match `diff-so-fancy` when using `delta diff-so-fancy` HOT 1
- 🐛 Emacs lisp incorrect highlighting HOT 1
- 🚀 hjkl key bindings as arrow keys HOT 2
- 🚀 Enable using delta in git when output is piped (`git diff | cat`) HOT 3
- 🚀 use diff-compatible exit statuses that differ between difference-found and error HOT 8
- 🚀 Please add support for cargo-binstall HOT 1
- 🐛 wrong highlight with `rg --json | delta` when tabs are involved HOT 2
- 🚀 `ws-error-highlight`
- 🐛 Homebrew cannot install from HEAD HOT 2
- 🐛 delta fails to run (in some cases) when `git` is not installed
- 🐛 White space before 2nd, 3rd `k` shouldn't be in highlighted scope
- 🐛 delta not respecting LESS -F environment variable (--quit-if-one-screen) HOT 2
- 🐛 Syntax highlighting fails when the visible snippet includes a multiline comment HOT 2
- 🐛 error: unexpected argument '--generate-completion' found
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from delta.