codespan icon indicating copy to clipboard operation
codespan copied to clipboard

Wrap lines to terminal width

Open brendanzab opened this issue 6 years ago • 6 comments

I'm thinking it might be useful to pass in an optional width for line wrapping in the Config struct. This would wrap lines and error messages. If we can figure out how to also include types like those from pretty, then these might be able to take advantage of this information as well.

brendanzab avatar Aug 25 '19 04:08 brendanzab

I ran into something similar, in the json-benchmark there is a 2mb canada.json almost all of of the contents being on a single line.

It might be nice to also have a Config option here for truncating leading strings from long lines, producing something like

 [19389 leading characters omitted] ...
 "foo", "bar", "baz",, 
                     ^ Expected `"String"`, found ","

I'm not sure if it deserved a separate report since it seemed somewhat related.

ratmice avatar Apr 08 '20 17:04 ratmice

I am opposed to this. If you wrap lines to terminal width, then the lines look really ugly whenever the user resizes the terminal. For example, this is what bat does:

   1 # Changelog
   2 
   3 The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
   4 and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
     .html).

and this is what it looks like when I resize my terminal:

2020-04-08-13:43:07

jyn514 avatar Apr 08 '20 17:04 jyn514

Just so I understand, you're opposed to this even when locked behind a Config?

ratmice avatar Apr 08 '20 17:04 ratmice

I guess if it's opt-in it would be ok, but it should still be documented that there's no way for codespan to handle terminal resizing. This is a common annoyance that I have with CLI programs, it also breaks copy/pasting.

jyn514 avatar Apr 08 '20 17:04 jyn514

This does seem like something tools should expose, kind of like the coloring of output - something like --wrap-lines auto|never|width=INT. This is an issue for tools like CI that don't really have any terminal width given.

brendanzab avatar Apr 09 '20 04:04 brendanzab

Just to add another vote for this one:

Screenshot from 2020-06-27 15-53-20

sophiajt avatar Jun 27 '20 03:06 sophiajt