Skip to content

Commit e462f96

Browse files
committed
Workaround for weird clipboard issues
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
1 parent 9dc3c24 commit e462f96

File tree

1 file changed

+17
-3
lines changed

1 file changed

+17
-3
lines changed

src/nvim/redraw_handler.rs

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -345,10 +345,24 @@ pub fn call_gui_request(
345345
let t = glib::MainContext::default()
346346
.block_on(clipboard.read_text_future())
347347
.unwrap_or(None)
348-
.unwrap_or_else(|| "".into());
349-
348+
.unwrap_or_else(|| "".into())
349+
.to_string()
350+
.replace("\r", "\n");
351+
352+
//Ok(Value::Array(vec![t.split('\n').to_owned()]))
353+
354+
/* Hello darkness my old friend
355+
* no.
356+
* I don't know why on earth we have suddenly gotten '\r' instead of '\n' in
357+
* pastes. But right now I've got more important stuff going in my life.
358+
* it literally happened one day
359+
* if you know, please contact lyude for a $0 reward
360+
*/
350361
Ok(Value::Array(
351-
t.split('\n').map(|s| s.into()).collect::<Vec<Value>>(),
362+
t.replace('\r', "\n")
363+
.split('\n')
364+
.map(|s| s.into())
365+
.collect::<Vec<Value>>(),
352366
))
353367
}
354368
opt => Err(format!("Unknown option: {opt}").into()),

0 commit comments

Comments
 (0)