From 2acc6327e4d8a05898b75cb3abb47b7941ec420a Mon Sep 17 00:00:00 2001 From: Hugo Herbelin Date: Sun, 7 Dec 2014 14:18:00 +0100 Subject: Protecting from a List.nth when applying a command, e.g. C-w, on no CoqIDE buffer. --- ide/nanoPG.ml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/ide/nanoPG.ml b/ide/nanoPG.ml index c6ac56992..671d85a17 100644 --- a/ide/nanoPG.ml +++ b/ide/nanoPG.ml @@ -294,8 +294,12 @@ let init w nb ags = let status = ref empty in let reset () = eprintf "reset\n%!"; cur := pg in ignore(w#event#connect#key_press ~callback:(fun t -> - if nb#current_term.script#misc#get_property "has-focus" <> - `BOOL true + let on_current_term f = + let term = try Some nb#current_term with Invalid_argument _ -> None in + match term with None -> false | Some t -> f t + in + on_current_term (fun x -> + if x.script#misc#get_property "has-focus" <> `BOOL true then false else begin eprintf "got key %s\n%!" (pr_key t); @@ -309,7 +313,7 @@ let init w nb ags = cur := c; true | `NotFound -> reset (); false end else false - end)); + end))); ignore(w#event#connect#button_press ~callback:(fun t -> reset (); false)) -- cgit v1.2.3