diff options
author | Ville Hakulinen <ville.hakulinen@gmail.com> | 2020-07-15 12:17:23 +0300 |
---|---|---|
committer | Ville Hakulinen <ville.hakulinen@gmail.com> | 2020-07-15 12:17:23 +0300 |
commit | 4dcf993222086ddf278e355e42d7c182e46eaccd (patch) | |
tree | d5e84d389382c5f938993c70a9fff3a18eae1cd2 | |
parent | 1becefc9e53a3b5ce2bd2d2d163b7b55bc65bfe2 (diff) |
Add sanity checks to grid_destroy & window_close
-rw-r--r-- | src/ui/state.rs | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/ui/state.rs b/src/ui/state.rs index 713dd67..8ac6c0d 100644 --- a/src/ui/state.rs +++ b/src/ui/state.rs @@ -203,7 +203,13 @@ impl UIState { } fn grid_destroy(&mut self, grid: &i64) { - self.grids.remove(grid).unwrap(); // Drop grid. + // Drop grid. + if self.grids.remove(grid).is_none() { + warn!( + "Nvim instructed to close a grid that we don't have (grid: {})", + grid + ); + } if self.windows.contains_key(grid) { self.windows.remove(grid).unwrap(); // Drop window that the grid belongs to. } @@ -672,8 +678,10 @@ impl UIState { } fn window_close(&mut self, grid_id: i64) { - // TODO(ville): Make sure all resources are dropped from the window. - self.windows.remove(&grid_id).unwrap(); // Drop window. + // Drop window. + if self.windows.remove(&grid_id).is_none() { + warn!("Nvim instructed to close a window that we don't have (grid: {})", grid_id); + } } fn msg_set_pos(&mut self, e: MsgSetPos) { |