Repository: tarkah/tickrs (language: rust)

Issue:
Crashes when window resizes to smallest possible size
Backtrace omitted. Run with RUST_BACKTRACE=1 to display it.
Run with RUST_BACKTRACE=full to include source snippets.

The application panicked (crashed).
  index out of bounds: the len is 62 but the index is 109     
in /home/runner/.cargo/registry/src/github.com-1ecc6299db9ec823/tui-0.9.5/src/buffer.rs, line 213



Backtrace omitted. Run with RUST_BACKTRACE=1 to display it.
Run with RUST_BACKTRACE=full to include source snippets.

The application panicked (crashed).
  called `Result::unwrap()` on an `Err` value: "PoisonError { inner: .. }"                   
in src/main.rs, line 139
thread: main


Easy to replicate on my KDE neon, run ./tickrs, resize window to the smallest size possible. Maybe a check for unwrap as it doesn't seem to work if the console window is small. (probably 0x0 since only the edges are visible) 

And I do mean smallest possible size: 
![image](https://user-images.githubusercontent.com/69441971/106473163-5f821080-649b-11eb-9a19-1d43207b4013.png)



Discussion / hints:
Thanks for the bug report! I'll try to add a fix for this today.

Fix patch:
diff --git a/src/draw.rs b/src/draw.rs
index d1969ff..e3bce5b 100644
--- a/src/draw.rs
+++ b/src/draw.rs
@@ -11,8 +11,14 @@ use tui::widgets::{Block, Borders, Paragraph, Tabs, Text};
 use tui::{Frame, Terminal};
 
 pub fn draw<B: Backend>(terminal: &mut Terminal<B>, app: &mut App) {
+    let current_size = terminal.size().unwrap_or_default();
+
+    if current_size.width <= 10 || current_size.height <= 10 {
+        return;
+    }
+
     if app.debug.enabled {
-        app.debug.dimensions = terminal.size().map_or((0, 0), |r| (r.width, r.height));
+        app.debug.dimensions = (current_size.width, current_size.height);
     }
 
     terminal


Test patch: