Skip to content

Commit 4c776b3

Browse files
committed
Avoid lag when nested array contains gb of data
1 parent afe6714 commit 4c776b3

File tree

4 files changed

+14
-11
lines changed

4 files changed

+14
-11
lines changed

src/array_table.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,11 @@ impl<'array> ArrayTable<'array> {
895895
return Some(label.ui(ui));
896896
} else if let Some(value) = entry.value.as_ref() {
897897
if !matches!(entry.pointer.value_type, ValueType::Null) {
898-
let label = CellText::new(value.clone());
898+
let label = if value.len() > 1000 {
899+
CellText::new(&value[0..1000])
900+
} else {
901+
CellText::new(value)
902+
};
899903

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

src/components/cell_text.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,21 @@ use eframe::epaint;
33
use egui::{FontSelection, Id, Response, RichText, Sense, Ui, WidgetText};
44

55
pub struct CellText {
6-
text: String,
6+
text: WidgetText,
77
}
88

99
impl CellText {
10-
pub fn new(text: String) -> CellText {
11-
CellText { text }
10+
pub fn new(text: impl Into<WidgetText>) -> CellText {
11+
CellText { text: text.into() }
1212
}
1313

1414
pub fn ui(self, ui: &mut Ui, cell_id: usize) -> Response {
1515
let rect = ui.available_rect_before_wrap();
1616
let cell_zone = ui.interact(rect, Id::new(cell_id), Sense::click());
1717

1818
let valign = ui.text_valign();
19-
let rich_text = RichText::new(self.text.clone());
2019

21-
let widget_text = WidgetText::RichText(rich_text);
20+
let widget_text = self.text;
2221
let mut layout_job =
2322
widget_text.into_layout_job(ui.style(), FontSelection::Default, valign);
2423

web/json-editor.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1645,23 +1645,23 @@ let wasm_bindgen;
16451645
const ret = false;
16461646
return ret;
16471647
};
1648-
imports.wbg.__wbindgen_closure_wrapper1017 = function(arg0, arg1, arg2) {
1648+
imports.wbg.__wbindgen_closure_wrapper1021 = function(arg0, arg1, arg2) {
16491649
const ret = makeMutClosure(arg0, arg1, 210, __wbg_adapter_32);
16501650
return ret;
16511651
};
1652-
imports.wbg.__wbindgen_closure_wrapper1517 = function(arg0, arg1, arg2) {
1652+
imports.wbg.__wbindgen_closure_wrapper1521 = function(arg0, arg1, arg2) {
16531653
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_35);
16541654
return ret;
16551655
};
1656-
imports.wbg.__wbindgen_closure_wrapper1519 = function(arg0, arg1, arg2) {
1656+
imports.wbg.__wbindgen_closure_wrapper1523 = function(arg0, arg1, arg2) {
16571657
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_35);
16581658
return ret;
16591659
};
1660-
imports.wbg.__wbindgen_closure_wrapper1521 = function(arg0, arg1, arg2) {
1660+
imports.wbg.__wbindgen_closure_wrapper1525 = function(arg0, arg1, arg2) {
16611661
const ret = makeMutClosure(arg0, arg1, 393, __wbg_adapter_40);
16621662
return ret;
16631663
};
1664-
imports.wbg.__wbindgen_closure_wrapper1933 = function(arg0, arg1, arg2) {
1664+
imports.wbg.__wbindgen_closure_wrapper1937 = function(arg0, arg1, arg2) {
16651665
const ret = makeMutClosure(arg0, arg1, 441, __wbg_adapter_43);
16661666
return ret;
16671667
};

web/json-editor_bg.wasm

617 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)