git-split-diffs icon indicating copy to clipboard operation
git-split-diffs copied to clipboard

Diff not using the full width of Git Bash

Open Velociraptor45 opened this issue 1 year ago • 8 comments

Hey there,

thanks for creating that amazing tool. However, I'm using the standard Git Bash that comes with the windows git installation and the diffs are not using the full window's width.

grafik

I'm starting the bash by default with a column count of 280 and did not resize it. I'll get a split diff up until a split-diffs.min-line-width of 60 - after that it's only inline. At first, I suspected it's because of my monitor's 150% scaling, but reverting that to 100% did not change anything. And in general it works: doing a git diff in window's cmd works perfectly and uses the console's full width.

And ideas why it's not working with the Git Bash?

Velociraptor45 avatar Sep 07 '22 18:09 Velociraptor45

Interesting, I use this library to figure out the terminal size in a cross platform manner: https://github.com/sindresorhus/term-size/blob/main/index.js. From reading the implementation, I'm guessing it's seeing a different value for process.platform than win32 and ending up falling through to the default of 80.

If you're comfortable with debugging this on your end, find your global node_modules (npm list -g will show you), then within it navigate to git-split-diffs/node_modules/term-size/index.js and add some console.log statements. Then if you run git diff again, those statements should print and show you where it is going wrong. Then we can maybe file an issue with https://github.com/sindresorhus/term-size/ to handle that edge case.

A less ideal workaround that might work is setting the COLUMNS and LINES environment variables that this library seems to read from. It's also possible that your mingw shell is setting these incorrectly and causing this issue.

banga avatar Sep 08 '22 01:09 banga

I did a little digging, and it seems like the library has a fallback (whatever this term-size.exe is doing) for windows if stderr.columns & stderr.rows is not filled. I opened an issue for Git Bash support with an implementation suggestion here https://github.com/sindresorhus/term-size/issues/22

Velociraptor45 avatar Sep 08 '22 17:09 Velociraptor45

Perfect, thanks!

banga avatar Sep 08 '22 22:09 banga