Use attributes at cursor position for insertions in Editor

This commit is contained in:
Héctor Ramón Jiménez 2023-09-17 22:35:41 +02:00
parent cb83458e7d
commit 0bb02227de
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -235,8 +235,12 @@ impl Edit for Editor {
let after_len = after.text().len();
// Collect attributes
let mut final_attrs = attrs_list
.unwrap_or_else(|| AttrsList::new(line.attrs_list().get_span(line.text().len())));
let mut final_attrs = attrs_list.unwrap_or_else(|| {
AttrsList::new(
line.attrs_list()
.get_span(self.cursor.index.saturating_sub(1)),
)
});
// Append the inserted text, line by line
// we want to see a blank entry if the string ends with a newline