Rewrite paste

- vim: support P for paste before
- vim: support P in visual mode for paste without overriding clipboard
- vim: fix position when using `p` on text copied outside zed
- vim: fix indentation when using `p` on text copied from zed
This commit is contained in:
Conrad Irwin 2023-08-21 12:55:59 -06:00
parent 31db5e4f62
commit 33d7fe02ee
14 changed files with 779 additions and 376 deletions

View file

@ -7,10 +7,16 @@ pub fn copy_selections_content(editor: &mut Editor, linewise: bool, cx: &mut App
let mut text = String::new();
let mut clipboard_selections = Vec::with_capacity(selections.len());
{
let mut is_first = true;
for selection in selections.iter() {
let initial_len = text.len();
let start = selection.start;
let end = selection.end;
if is_first {
is_first = false;
} else {
text.push_str("\n");
}
let initial_len = text.len();
for chunk in buffer.text_for_range(start..end) {
text.push_str(chunk);
}