fix for test.sh

This commit is contained in:
Stewart Connor 2025-03-31 17:03:51 +11:00
parent 53763c157b
commit e828131c92
15 changed files with 136 additions and 109 deletions

View file

@ -380,7 +380,7 @@ impl<'buffer> Edit<'buffer> for Editor<'buffer> {
let line = BufferLine::new(
String::new(),
ending,
AttrsList::new(attrs_list.as_ref().map_or_else(
AttrsList::new(&attrs_list.as_ref().map_or_else(
|| {
buffer
.lines
@ -404,7 +404,7 @@ impl<'buffer> Edit<'buffer> for Editor<'buffer> {
// Collect attributes
let mut final_attrs = attrs_list.unwrap_or_else(|| {
AttrsList::new(line.attrs_list().get_span(cursor.index.saturating_sub(1)))
AttrsList::new(&line.attrs_list().get_span(cursor.index.saturating_sub(1)))
});
// Append the inserted text, line by line

View file

@ -88,7 +88,7 @@ impl<'syntax_system, 'buffer> SyntaxEditor<'syntax_system, 'buffer> {
foreground.a,
));
}
line.set_attrs_list(AttrsList::new(attrs));
line.set_attrs_list(AttrsList::new(&attrs));
}
});
}
@ -125,7 +125,7 @@ impl<'syntax_system, 'buffer> SyntaxEditor<'syntax_system, 'buffer> {
let text = fs::read_to_string(path)?;
self.editor.with_buffer_mut(|buffer| {
buffer.set_text(font_system, &text, attrs, Shaping::Advanced);
buffer.set_text(font_system, &text, &attrs, Shaping::Advanced);
});
//TODO: re-use text
@ -332,9 +332,11 @@ impl<'buffer> Edit<'buffer> for SyntaxEditor<'_, 'buffer> {
);
let attrs = line.attrs_list().defaults();
let mut attrs_list = AttrsList::new(attrs);
let mut attrs_list = AttrsList::new(&attrs);
let original_attrs = attrs.clone(); // Store a clone for comparison
for (style, _, range) in ranges {
let span_attrs = attrs
.clone() // Clone attrs for modification
.color(Color::rgba(
style.foreground.r,
style.foreground.g,
@ -352,8 +354,8 @@ impl<'buffer> Edit<'buffer> for SyntaxEditor<'_, 'buffer> {
} else {
Weight::NORMAL
}); //TODO: underline
if span_attrs != attrs {
attrs_list.add_span(range, span_attrs);
if span_attrs != original_attrs {
attrs_list.add_span(range, &span_attrs);
}
}