Commit fd7996d9df

fd7996d9df6b56ed7311f09c86369e1cc31c7585

parent: f41c0519f9

Unsigned

Damir Jelić <poljar@termina.org.uk> · 2021-03-02 16:55 UTC

room: Fix a panic on debug builds in the local echo rendering logic

Layout: unified · split

src/room/mod.rs +5 −6
@@ -853,20 +853,19 @@ impl MatrixRoom {
853853 let line_contains_uuid = |l: &BufferLine| l.tags().contains(&uuid_tag);
854854
855855 let mut lines = buffer.lines();
856 let mut first_line = lines.rfind(line_contains_uuid);
856 let mut current_line = lines.rfind(line_contains_uuid);
857857
858858 // We go in reverse order here since we also use rfind(). We got from
859859 // the bottom of the buffer to the top since we're expecting these
860860 // lines to be freshly printed and thus at the bottom.
861 let mut line_num = rendered.content.lines.len() - 1;
861 let mut line_num = rendered.content.lines.len();
862862
863 while let Some(line) = &first_line {
863 while let Some(line) = &current_line {
864 line_num -= 1;
864865 let rendered_line = &rendered.content.lines[line_num];
865866
866867 line.set_message(&rendered_line.message);
867
868 line_num -= 1;
869 first_line = lines.next_back().filter(line_contains_uuid);
868 current_line = lines.next_back().filter(line_contains_uuid);
870869 }
871870 }
872871