diff --git a/daemon.fs b/daemon.fs index 7b95b1d..152da1d 100644 --- a/daemon.fs +++ b/daemon.fs @@ -190,7 +190,10 @@ let fvrConnect (stdin: Stream) (stdout: Stream) (verb: FVimRemoteVerb) = stdin.Write(intbuf, 0, intbuf.Length) stdin.Write(payload, 0, payload.Length) stdin.Flush() - (read stdout (intbuf.AsMemory())).Wait() + // this doesn't drive the task: + // (read stdout (intbuf.AsMemory())).Wait() + // this *does* drive the task: + read stdout (intbuf.AsMemory()) |> Async.AwaitTask |> Async.StartImmediate toInt32LE intbuf with ex -> trace "%O" ex diff --git a/model.fs b/model.fs index cdd9c96..553913f 100644 --- a/model.fs +++ b/model.fs @@ -627,11 +627,17 @@ let OnTerminated () = trace "terminating nvim..." nvim.stop 1 +let mutable _detaching = false + let OnTerminating(args: CancelEventArgs) = - args.Cancel <- true trace "window is closing" - if nvim.isRemote then Detach() - else nvim.quitall() |> ignore + if nvim.isRemote then + if not _detaching then + _detaching <- true + Detach() + else + args.Cancel <- true + nvim.quitall() |> ignore let OnExtClosed(win: int) = nvim.call {method = "nvim_win_close"; parameters = mkparams2 win true}