Canop / bacon

background rust code check
https://dystroy.org/bacon
GNU Affero General Public License v3.0
1.93k stars 71 forks source link

Wrapping inserts a space which causes copy-paste and url clicking to fail #125

Open joshka opened 1 year ago

joshka commented 1 year ago

When the terminal width is not as wide as the message, the message wraps (which is good). The problem however is that at the wrap point, a space is inserted. This prevents terminal apps (iterm2 in my case) from detecting that a url has continued onto the next line. It also inserts a space into any text copied, which makes it annoying to copy past a suggested fix.

Example:

 1  warning: use Option::map_or_else instead of an if let/else
    --> src/view/login.rs:180:21
     |
 180 | /                     match self.authentication_code.as_ref() {
 181 | |                         Some(code) => Transition::To(LoginState::Com.
 ..
 182 | |                         None => Transition::None,
 183 | |                     }
     | |_____________________^ help: try: `self.authentication_code.as_ref().m
 ap_or_else(|| Transition::None, |code| Transition::To(LoginState::CompleteAut
 hentication(registered.clone(), code.clone())))`
     |
     = help: for further information visit https://rust-lang.github.io/rust-cl
 ippy/master/index.html#option_if_let_else
     = note: `-W clippy::option-if-let-else` implied by `-W clippy::nursery`

Causes two problems:

  1. This cannot be pasted as a solution to the problem:
    self.authentication_code.as_ref().m
    ap_or_else(|| Transition::None, |code| Transition::To(LoginState::CompleteAut
    hentication(registered.clone(), code.clone())))
  2. This cannot be clicked to understand the problem better:
    https://rust-lang.github.io/rust-cl
    ippy/master/index.html#option_if_let_else

Suggested fix: Don't add the extra space when wrapping

Canop commented 1 year ago

If we remove this indentation, you'll still have the problem due to the scrollbar, as soon as the report doesn't fit the height.

joshka commented 1 year ago

Hrm, I didn't realize that there was a scrollbar :D You're right that is a problem. A workaround that could work might be to wrap urls in OSC 8 sequences (though perhaps that should be an upstream request on clippy. Do you happen to know how much processing of the clippy output gets done? Would OSC codes like this be passed through verbatim, or need to be explicitly handled by bacon?

TL;DR in case you've never seen this, the OSC 8 escape sequence:

printf '\e]8;;http://example.com/long-link-that-spans-multiple-lines\e\\https://example.com/long-link-\nthat-spans-multiple-lines\e]8;;\e\\\n'

Makes links clickable as the full link not the truncated link:

image

That addresse problem 2, but not problem 1. My guess is that problem 1 would only be fixable by turning off the scroll bar (perhaps moving the scroll position to the status bar?)

This is not a high priority item - more an annoyance than anything.