Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/edit/src/bin/edit/draw_menubar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn draw_menu_edit(ctx: &mut Context, state: &mut State) {
ctx.needs_rerender();
}
if ctx.menubar_menu_button(loc(LocId::EditPaste), 'P', kbmod::CTRL | vk::V) {
tb.paste(ctx.clipboard_ref());
tb.paste(ctx.clipboard_ref(), false);
ctx.needs_rerender();
}
if state.wants_search.kind != StateSearchKind::Disabled {
Expand Down
11 changes: 10 additions & 1 deletion crates/edit/src/buffer/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2242,8 +2242,17 @@ impl TextBuffer {
clipboard.write_was_line_copy(line_copy);
}

pub fn paste(&mut self, clipboard: &Clipboard) {
pub fn paste(&mut self, clipboard: &Clipboard, single_line: bool) {
let data = clipboard.read();

let data = if single_line {
// Can't use `unicode::newlines_forward` because bracketed paste uses CR instead of LF/CRLF.
let off = memchr2(b'\r', b'\n', data, 0);
unicode::strip_newline(&data[..off])
} else {
data
};

if data.is_empty() {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions crates/edit/src/tui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2680,7 +2680,7 @@ impl<'a> Context<'a, '_> {
}
}
vk::INSERT => match modifiers {
kbmod::SHIFT => tb.paste(self.clipboard_ref()),
kbmod::SHIFT => tb.paste(self.clipboard_ref(), single_line),
kbmod::CTRL => tb.copy(self.clipboard_mut()),
_ => tb.set_overtype(!tb.is_overtype()),
},
Expand Down Expand Up @@ -2726,7 +2726,7 @@ impl<'a> Context<'a, '_> {
_ => return false,
},
vk::V => match modifiers {
kbmod::CTRL => tb.paste(self.clipboard_ref()),
kbmod::CTRL => tb.paste(self.clipboard_ref(), single_line),
_ => return false,
},
vk::Y => match modifiers {
Expand Down
Loading