Commit c7bfa47b05

c7bfa47b05e52fa740902edd445c54ba91e72fb1

parent: 5d668724e1

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
@@ -850,20 +850,19 @@ impl MatrixRoom {
850850 let line_contains_uuid = |l: &BufferLine| l.tags().contains(&uuid_tag);
851851
852852 let mut lines = buffer.lines();
853 let mut first_line = lines.rfind(line_contains_uuid);
853 let mut current_line = lines.rfind(line_contains_uuid);
854854
855855 // We go in reverse order here since we also use rfind(). We got from
856856 // the bottom of the buffer to the top since we're expecting these
857857 // lines to be freshly printed and thus at the bottom.
858 let mut line_num = rendered.content.lines.len() - 1;
858 let mut line_num = rendered.content.lines.len();
859859
860 while let Some(line) = &first_line {
860 while let Some(line) = &current_line {
861 line_num -= 1;
861862 let rendered_line = &rendered.content.lines[line_num];
862863
863864 line.set_message(&rendered_line.message);
864
865 line_num -= 1;
866 first_line = lines.next_back().filter(line_contains_uuid);
865 current_line = lines.next_back().filter(line_contains_uuid);
867866 }
868867 }
869868