Skip to content

Commit

Permalink
fix bug making changes made when closed not show immediately on opening
Browse files Browse the repository at this point in the history
  • Loading branch information
faldor20 committed Oct 5, 2024
1 parent 2c9248d commit 78c7319
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
29 changes: 20 additions & 9 deletions jj_tui/bin/global_funcs.ml
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ let list_files ?(rev = "@") () =
;;

let check_startup () =
match jj_no_log_errorable ~color:false ~snapshot:false [ "op";"log"; "-l";"0" ] with
| Ok _ ->
`Good
| Error (`BadExit (i, str)) ->
if str |> Base.String.is_substring ~substring:"There is no jj repo"
then `NotInRepo
else `OtherError str
| Error (`Exception e) ->
`CantStartProcess e
let result = Lwd.var `Good in
(* In the happy path making this a fiber and returning an Lwd.t makes this not delay rendering. In the unhappy path, after 150-50ms the error message will show*)
Flock.fork (fun x ->
let res =
match
(*we snapshot here in the first request to make sure the editor is showing the latest changes*)
jj_no_log_errorable ~color:false ~snapshot:true [ "op"; "log"; "-l"; "0" ]
with
| Ok _ ->
`Good
| Error (`BadExit (i, str)) ->
if str |> Base.String.is_substring ~substring:"There is no jj repo"
then `NotInRepo
else `OtherError str
| Error (`Exception e) ->
`CantStartProcess e
in
(*we don't want to trigger a re-render if the result is still good *)
if res != Lwd.peek result then result $= res);
result |> Lwd.get
;;

(**Updates the status windows; Without snapshotting the working copy by default
Expand Down
16 changes: 7 additions & 9 deletions jj_tui/bin/jj_ui.ml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ module Make (Vars : Global_vars.Vars) = struct
W.button (Printf.sprintf "quit ") (fun () -> Vars.quit $= true) |> Lwd.pure
;;


let inputs ?(custom = fun _ -> `Unhandled) ui =
let$ input_state = Lwd.get ui_state.input
and$ ui = ui in
Expand All @@ -46,10 +45,10 @@ module Make (Vars : Global_vars.Vars) = struct
match custom event with
| `Unhandled ->
(match event with
| `Arrow (`Left), _ ->
`Remap (`Focus `Up,[])
| `Arrow (`Right), _ ->
`Remap (`Focus `Down,[])
| `Arrow `Left, _ ->
`Remap (`Focus `Up, [])
| `Arrow `Right, _ ->
`Remap (`Focus `Down, [])
| `ASCII 'q', _ ->
Vars.quit $= true;
`Handled
Expand Down Expand Up @@ -145,7 +144,6 @@ module Make (Vars : Global_vars.Vars) = struct
|> W.Overlay.selection_list_prompt_filterable
~show_prompt_var:ui_state.show_string_selection_prompt
|> inputs ~custom:(function
| `Enter, [] ->
Focus.request_reversable summary_focus;
`Handled
Expand All @@ -169,14 +167,14 @@ module Make (Vars : Global_vars.Vars) = struct
let mainUi () =
(*we want to initialize our states and keep them up to date*)
match check_startup () with
let$* startup_result = check_startup () in
match startup_result with
| `Good ->
(* update_status ~cause_snapshot:true (); *)
Flock.fork (fun () ->
while true do
Picos.Fiber.sleep ~seconds:5.0;
(*we need to lock this becasue we could end up updating while the ui is rendering*)
update_status ~cause_snapshot:true ()
(*we need to lock this becasue we could end up updating while the ui is rendering*)
done;
());
let$* running = Lwd.get ui_state.view in
Expand Down

0 comments on commit 78c7319

Please sign in to comment.