Skip to content

Commit

Permalink
Workaround for weird clipboard issues
Browse files Browse the repository at this point in the history
I have no idea why or how this started, but as of late it seems like the
input that we're getting from GTK's clipboard is using the wrong newline
character. Workaround it manually for now, but we need to figure out a
better fix for this in the future
  • Loading branch information
Lyude committed Sep 10, 2024
1 parent 9dc3c24 commit e462f96
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions src/nvim/redraw_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,24 @@ pub fn call_gui_request(
let t = glib::MainContext::default()
.block_on(clipboard.read_text_future())
.unwrap_or(None)
.unwrap_or_else(|| "".into());

.unwrap_or_else(|| "".into())
.to_string()
.replace("\r", "\n");

//Ok(Value::Array(vec![t.split('\n').to_owned()]))

/* Hello darkness my old friend
* no.
* I don't know why on earth we have suddenly gotten '\r' instead of '\n' in
* pastes. But right now I've got more important stuff going in my life.
* it literally happened one day
* if you know, please contact lyude for a $0 reward
*/
Ok(Value::Array(
t.split('\n').map(|s| s.into()).collect::<Vec<Value>>(),
t.replace('\r', "\n")
.split('\n')
.map(|s| s.into())
.collect::<Vec<Value>>(),
))
}
opt => Err(format!("Unknown option: {opt}").into()),
Expand Down

0 comments on commit e462f96

Please sign in to comment.