Record start columns when writing to the clipboard from Zed

This commit is contained in:
Max Brunsfeld 2022-07-28 18:09:24 -07:00
parent 2d05f906f1
commit 7a26fa18c7
5 changed files with 214 additions and 45 deletions

View file

@ -1,5 +1,6 @@
use editor::{ClipboardSelection, Editor};
use gpui::{ClipboardItem, MutableAppContext};
use std::cmp;
pub fn copy_selections_content(editor: &mut Editor, linewise: bool, cx: &mut MutableAppContext) {
let selections = editor.selections.all_adjusted(cx);
@ -17,6 +18,10 @@ pub fn copy_selections_content(editor: &mut Editor, linewise: bool, cx: &mut Mut
clipboard_selections.push(ClipboardSelection {
len: text.len() - initial_len,
is_entire_line: linewise,
first_line_indent: cmp::min(
start.column,
buffer.indent_size_for_line(start.row).len,
),
});
}
}