···11431143 ) !void {
11441144 if (channel.messages.items.len == 0) return;
11451145 const client = channel.client;
11461146- const messages = channel.messages.items[0 .. channel.messages.items.len - self.state.messages.scroll_offset];
11461146+ const last_msg_idx = channel.messages.items.len -| self.state.messages.scroll_offset;
11471147+ const messages = channel.messages.items[0..@max(1, last_msg_idx)];
11471148 // We draw a gutter for time information
11481149 const gutter_width: usize = 6;
11491150···11721173 );
1173117411741175 // Define a few state variables for the loop
11751175- const last_msg = messages[messages.len - 1];
11761176+ const last_msg = messages[messages.len -| 1];
1176117711771178 // Initialize prev_time to the time of the last message, falling back to "now"
11781179 var prev_time: zeit.Instant = last_msg.localTime(&self.tz) orelse