Skip to content
Snippets Groups Projects
Unverified Commit fa8e49b4 authored by sam's avatar sam Committed by GitHub
Browse files

fix no focus causing failed rendering (#97)

parent 28e00c94
No related branches found
No related tags found
No related merge requests found
......@@ -507,12 +507,17 @@ fn cosmic_editor_builder(
mut commands: Commands,
) {
for (entity, metrics) in added_editors.iter_mut() {
let buffer = Buffer::new(
let mut buffer = Buffer::new(
&mut font_system.0,
Metrics::new(metrics.font_size, metrics.line_height).scale(metrics.scale_factor),
);
// buffer.set_wrap(&mut font_system.0, cosmic_text::Wrap::None);
let editor = Editor::new(buffer);
buffer.set_redraw(true);
let mut editor = Editor::new(buffer);
let mut cursor = editor.cursor();
cursor.color = Some(cosmic_text::Color::rgba(0, 0, 0, 0));
editor.set_cursor(cursor);
commands.entity(entity).insert(CosmicEditor(editor));
commands.entity(entity).insert(CosmicEditHistory::default());
......
......@@ -429,14 +429,14 @@ pub(crate) fn hide_inactive_or_readonly_cursor(
editor.0.buffer_mut().set_redraw(true);
}
if active_editor.is_changed() || active_editor.0.is_none() {
return;
}
for (e, mut editor, readonly_opt) in &mut cosmic_editor_q_placeholder.iter_mut() {
if e != active_editor.0.unwrap() || readonly_opt.is_some() {
// filthy short circuiting instead of correct unwrapping
if active_editor.is_none() || e != active_editor.0.unwrap() || readonly_opt.is_some() {
let editor = &mut editor.0;
let mut cursor = editor.0.cursor();
if cursor.color == Some(cosmic_text::Color::rgba(0, 0, 0, 0)) {
return;
}
cursor.color = Some(cosmic_text::Color::rgba(0, 0, 0, 0));
editor.0.set_cursor(cursor);
editor.0.buffer_mut().set_redraw(true);
......@@ -444,8 +444,11 @@ pub(crate) fn hide_inactive_or_readonly_cursor(
}
for (e, mut editor) in &mut cosmic_editor_q_editable.iter_mut() {
if e != active_editor.0.unwrap() {
if active_editor.is_none() || e != active_editor.0.unwrap() {
let mut cursor = editor.0.cursor();
if cursor.color == Some(cosmic_text::Color::rgba(0, 0, 0, 0)) {
return;
}
cursor.color = Some(cosmic_text::Color::rgba(0, 0, 0, 0));
editor.0.set_cursor(cursor);
editor.0.buffer_mut().set_redraw(true);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment