fn session_with_new_neovim_process(cli_ctx: &context::CliContext) -> (neovim_lib::Session, Option<process::Child>) {
        let context::CliContext { opt, tmp_dir, page_id, print_protection, .. } = cli_ctx;
        if *print_protection {
            print_redirect_protection(&tmp_dir);
        }
        let p = tmp_dir.clone().join(&format!("socket-{}", page_id));
        let nvim_listen_addr = p.to_string_lossy();
        let nvim_proc = spawn_child_nvim_process(opt, &nvim_listen_addr);
        let mut i = 0;
        let e = loop {
            match session_at_address(&nvim_listen_addr) {
                Ok(nvim_session) => return (nvim_session, Some(nvim_proc)),
                Err(e) => {
                    if let std::io::ErrorKind::NotFound = e.kind() {
                        if i == 100 {
                            break e
                        } else {
                            log::trace!(target: "cannot connect to child neovim", "[attempt #{}] address '{}': {:?}", i, nvim_listen_addr, e);
                            std::thread::sleep(std::time::Duration::from_millis(16));
                            i += 1
                        }
                    } else {
                        break e
                    }
                }
            }
        };
        panic!("Cannot connect to neovim: {:?}", e);
    }
/// Creates a new session using UNIX socket.
/// Also prints protection from shell redirection that could cause some harm (see --help[-W])
Creates a new session using UNIX socket.
Also prints protection from shell redirection that could cause some harm
Creates a new session using UNIX socket . Also prints protection from shell redirection that could cause some harm
fn session_with_new_neovim_process(cli_ctx: &context::CliContext) -> (neovim_lib::Session, Option<process::Child>) {
        let context::CliContext { opt, tmp_dir, page_id, print_protection, .. } = cli_ctx;
        if *print_protection {
            print_redirect_protection(&tmp_dir);
        }
        let p = tmp_dir.clone().join(&format!("socket-{}", page_id));
        let nvim_listen_addr = p.to_string_lossy();
        let nvim_proc = spawn_child_nvim_process(opt, &nvim_listen_addr);
        let mut i = 0;
        let e = loop {
            match session_at_address(&nvim_listen_addr) {
                Ok(nvim_session) => return (nvim_session, Some(nvim_proc)),
                Err(e) => {
                    if let std::io::ErrorKind::NotFound = e.kind() {
                        if i == 100 {
                            break e
                        } else {
                            log::trace!(target: "cannot connect to child neovim", "[attempt #{}] address '{}': {:?}", i, nvim_listen_addr, e);
                            std::thread::sleep(std::time::Duration::from_millis(16));
                            i += 1
                        }
                    } else {
                        break e
                    }
                }
            }
        };
        panic!("Cannot connect to neovim: {:?}", e);
    }
fn session_with_new_neovim_process ( cli_ctx : & context :: CliContext ) -> ( neovim_lib :: Session , Option < process :: Child > ) { let context :: CliContext { opt , tmp_dir , page_id , print_protection , .. } = cli_ctx ; if * print_protection { print_redirect_protection ( & tmp_dir ) ; } let p = tmp_dir . clone ( ) . join ( & format ! ( " " page_id ) ) ; let nvim_listen_addr = p . to_string_lossy ( ) ; let nvim_proc = spawn_child_nvim_process ( opt , & nvim_listen_addr ) ; let mut i = 0 ; let e = loop { match session_at_address ( & nvim_listen_addr ) { Ok ( nvim_session ) => return ( nvim_session , Some ( nvim_proc ) ) , Err ( e ) => { if let std :: io :: ErrorKind :: NotFound = e . kind ( ) { if i == 100 { break e } else { log :: trace ! ( target " " " " i nvim_listen_addr e ) ; std :: thread :: sleep ( std :: time :: Duration :: from_millis ( 16 ) ) ; i += 1 } } else { break e } } } } ; panic ! ( " " e ) ; }
Creates a new session using UNIX socket.
Creates a new session using UNIX socket .
cli_ctx
&context::CliContext
cli_ctx
&context::CliContext