Skip to content

Commit

Permalink
Use break on newline from layout job instead of replace in string
Browse files Browse the repository at this point in the history
  • Loading branch information
nmeylan committed Jan 2, 2025
1 parent 46973db commit a0389b3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/array_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ impl<'array>
}
}


pub const NON_NULL_FILTER_VALUE: &str = "__non_null";

impl<'array> ArrayTable<'array> {
Expand Down Expand Up @@ -892,18 +893,13 @@ impl<'array> ArrayTable<'array> {
}
} else if let Some(index) = index {
let entry = &row_data.entries()[index];
let is_array = matches!(entry.pointer.value_type, ValueType::Array(_));
let is_object = matches!(entry.pointer.value_type, ValueType::Object(..));

if pinned_column_table && col_index == 0 {
let label = Label::new(row_index.to_string());
return Some(label.ui(ui));
} else if let Some(value) = entry.value.as_ref() {
if !matches!(entry.pointer.value_type, ValueType::Null) {
let mut label = if is_array || is_object {
CellText::new(value.replace('\n', "")) // maybe we want cache
} else {
CellText::new(value.clone())
};
let mut label = CellText::new(value.clone());

let mut response = label.ui(ui, cell_id);

Expand Down
1 change: 1 addition & 0 deletions src/components/cell_text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ impl CellText {
let widget_text = WidgetText::RichText(rich_text);
let mut layout_job = widget_text.into_layout_job(ui.style(), FontSelection::Default, valign);

layout_job.break_on_newline = false;
layout_job.wrap.max_width = f32::INFINITY;
layout_job.halign = Align::LEFT;
layout_job.justify = false;
Expand Down

0 comments on commit a0389b3

Please sign in to comment.