From 204eb1441f2963fd4a0a922f642cd3737e683c8e Mon Sep 17 00:00:00 2001 From: Darren Li Date: Sat, 14 Sep 2024 12:57:12 +1000 Subject: [PATCH] Fixing single file view crash --- CHANGELOG.md | 4 ++++ bin/single_file_view.ml | 43 +++++++++++++++++++++-------------------- bin/version_string.ml | 2 +- 3 files changed, 27 insertions(+), 22 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c685400..ee0a537 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changelog +## 8.0.3 + +- Fixed single file view crash + ## 8.0.2 - Reworked asynchronous search/filter UI code to avoid noticeable lag due to diff --git a/bin/single_file_view.ml b/bin/single_file_view.ml index 55ce4d3..122c120 100644 --- a/bin/single_file_view.ml +++ b/bin/single_file_view.ml @@ -331,24 +331,25 @@ let main : Nottui.ui Lwd.t = let$* document_store = Lwd.get Document_store_manager.single_file_view_document_store in - let _, document_info = - Option.get (Document_store.min_binding document_store) - in - let$* bottom_pane = Bottom_pane.main ~document_info in - let bottom_pane_height = Nottui.Ui.layout_height bottom_pane in - let$* (term_width, term_height) = Lwd.get Ui_base.Vars.term_width_height in - let top_pane_height = term_height - bottom_pane_height in - let$* top_pane = - Top_pane.main - ~width:term_width - ~height:top_pane_height - ~document_info - in - Nottui_widgets.vbox - [ - Lwd.return ( - Nottui.Ui.keyboard_area - (keyboard_handler ~document_info) - top_pane); - Lwd.return bottom_pane; - ] + match Document_store.min_binding document_store with + | None -> Lwd.return (Nottui.Ui.atom (Notty.I.void 0 0)) + | Some (_, document_info) -> ( + let$* bottom_pane = Bottom_pane.main ~document_info in + let bottom_pane_height = Nottui.Ui.layout_height bottom_pane in + let$* (term_width, term_height) = Lwd.get Ui_base.Vars.term_width_height in + let top_pane_height = term_height - bottom_pane_height in + let$* top_pane = + Top_pane.main + ~width:term_width + ~height:top_pane_height + ~document_info + in + Nottui_widgets.vbox + [ + Lwd.return ( + Nottui.Ui.keyboard_area + (keyboard_handler ~document_info) + top_pane); + Lwd.return bottom_pane; + ] + ) diff --git a/bin/version_string.ml b/bin/version_string.ml index d0cdf4b..39a65fc 100644 --- a/bin/version_string.ml +++ b/bin/version_string.ml @@ -1 +1 @@ -let s = "8.0.2" +let s = "8.0.3"