Use RPC requests instead of notify for quit requests (#2312)

This commit is contained in:
fredizzimo 2024-01-27 08:12:54 +02:00 committed by GitHub
parent e497ec7771
commit 879172ec07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 8 additions and 7 deletions

View file

@ -94,7 +94,7 @@ vim.api.nvim_create_autocmd({ "VimLeavePre" }, {
once = true,
nested = true,
callback = function()
rpcnotify("neovide.quit", vim.v.exiting)
rpcrequest("neovide.quit", vim.v.exiting)
end
})

View file

@ -62,6 +62,13 @@ impl Handler for NeovimHandler {
}
"neovide.set_clipboard" => set_clipboard_contents(&arguments[0])
.map_err(|_| Value::from("cannot set clipboard contents")),
"neovide.quit" => {
let error_code = arguments[0]
.as_i64()
.expect("Could not parse error code from neovim");
RUNNING_TRACKER.quit_with_code(error_code as i32, "Quit from neovim");
Ok(Value::Nil)
}
_ => Ok(Value::from("rpcrequest not handled")),
}
}
@ -92,12 +99,6 @@ impl Handler for NeovimHandler {
"option_changed" => {
SETTINGS.handle_option_changed_notification(arguments, &self.proxy.lock().unwrap());
}
"neovide.quit" => {
let error_code = arguments[0]
.as_i64()
.expect("Could not parse error code from neovim");
RUNNING_TRACKER.quit_with_code(error_code as i32, "Quit from neovim");
}
#[cfg(windows)]
"neovide.register_right_click" => {
let _ = self