From bdf55ecdc2f6deb5900b76f7110d913399b5225c Mon Sep 17 00:00:00 2001 From: marc2332 Date: Sun, 5 May 2024 21:53:19 +0200 Subject: [PATCH] fix: Panic when editing sometimes --- src/tabs/editor/editor_line.rs | 31 ++++++++++++------------------- 1 file changed, 12 insertions(+), 19 deletions(-) diff --git a/src/tabs/editor/editor_line.rs b/src/tabs/editor/editor_line.rs index 091198f..58fe12e 100644 --- a/src/tabs/editor/editor_line.rs +++ b/src/tabs/editor/editor_line.rs @@ -174,29 +174,22 @@ pub fn EditorLine( font_size: "{font_size}", font_family: "Jetbrains Mono", {line.iter().enumerate().map(|(i, (syntax_type, text))| { - match text { + let text = match text { TextNode::Range(word_pos) => { - let text = rope.slice(word_pos.clone()); - rsx!( - text { - key: "{i}", - color: "{syntax_type.color()}", - "{text}" - } - ) - + rope.slice(word_pos.clone()).to_string() }, TextNode::LineOfChars { len, char } => { - let text = format!("{char}").repeat(*len); - rsx!( - text { - key: "{i}", - color: "{syntax_type.color()}", - "{text}" - } - ) + format!("{char}").repeat(*len) } - } + }; + + rsx!( + text { + key: "{i}", + color: "{syntax_type.color()}", + "{text}" + } + ) })} } }