Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bat hard-wraps if any decorations are enabled even if they don't affect line layout #1740

Open
lilyball opened this issue Jul 20, 2021 · 3 comments
Labels
bug Something isn't working

Comments

@lilyball
Copy link

Describe the bug you encountered:

bat will soft-wrap text if I use --style=plain, meaning resizing the window works, copying wrapped lines works correctly, and jumping to a specific line in less works. But it hard-wraps if I enable any decorations, even if the decorations don't affect the horizontal layout. This is really frustrating. Even if I don't want to resize the window, the fact that it breaks copying of wrapped lines (by inserting a newline) is a problem, and the fact that I can't jump to a given line (taking header height into account) in less is annoying too.

This happens even if the decoration in question isn't affecting output, such as bat --style=snip without setting line ranges. Or if the decoration is completely unaffected by window width, such as bat --style=header

What did you expect to happen instead?

Bat should soft-wrap any line whose layout is not dependent upon decorations. I believe right now that means it should soft-wrap as long as I did not enable the numbers or changes decorations. Or to put it another way, if there's no gutter, or equivalently if the grid decoration would not draw a vertical line, then it should soft-wrap.

How annoying is this?

It's annoying enough that I have --style=plain in my config, even though I'd really prefer to have something like --style=header,grid,snip. But copying of wrapped lines and jumping to line numbers in less are both so important that I have no choice.

How did you install bat?

Nix


bat version and environment

Software version

bat 0.18.0

Operating system

Darwin 20.5.0

Command-line

/Users/lily/.nix-profile/bin/bat --style=header some_file --diagnostic 

Environment variables

SHELL=/Users/lily/.local/share/home-manager/bin/fish
PAGER='less -R'
BAT_PAGER=<not set>
BAT_CACHE_PATH=<not set>
BAT_CONFIG_PATH=<not set>
BAT_OPTS=<not set>
BAT_STYLE=<not set>
BAT_TABS=<not set>
BAT_THEME=<not set>
XDG_CONFIG_HOME=<not set>
XDG_CACHE_HOME=<not set>
COLORTERM=<not set>
NO_COLOR=<not set>
MANPAGER=<not set>

Config file

#--theme base16
--italic-text always
--map-syntax *.jenkinsfile:Groovy
--style=plain

Compile time information

  • Profile: release
  • Target triple: x86_64-apple-darwin
  • Family: unix
  • OS: macos
  • Architecture: x86_64
  • Pointer width: 64
  • Endian: little
  • CPU features: fxsr,sse,sse2,sse3,ssse3
  • Host: x86_64-apple-darwin

Less version

> less --version 
less 563 (POSIX regular expressions)
Copyright (C) 1984-2020  Mark Nudelman

less comes with NO WARRANTY, to the extent permitted by law.
For information about the terms of redistribution,
see the file named README in the less distribution.
Home page: http://www.greenwoodsoftware.com/less
@lilyball lilyball added the bug Something isn't working label Jul 20, 2021
@sharkdp
Copy link
Owner

sharkdp commented Jul 23, 2021

Thank you for reporting this.

Just to make sure: did you see the --wrap option? The following should hopefully work fine:

--style=header,grid,snip --wrap=never

@lilyball
Copy link
Author

I did notice that option after filing this issue I set it in my config because it disables soft wrapping in less as well (though I can re-enable it interactively with -S). And if I work around that, then this will probably confuse me the next time I try bat --style=full.

lindhe added a commit to lindhe/dotfiles that referenced this issue Oct 15, 2023
It's a work-around for this issue:

sharkdp/bat#1740
@Arian04
Copy link

Arian04 commented May 5, 2024

Just wanted to add that this same issue bothers me.

My issue with --wrap=never is that it triggers the pager interactively when lines are too long, whereas without it, the paging is only activated automatically when there are enough lines.

The reason I want to disable wrapping without this side-effect is because I don't like having to remove the newlines when copy-pasting (or having to switch to cat once I realize they're there).

Ex: Using --style="rule,snip" in my config when running bat .ssh/id_rsa.pub causes hard wrapping, whereas --style="plain" works perfectly even though rule and snip aren't even applicable for that invocation of the command, since it's only one file with no given line range.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants