don't parse version number from client info (#1166)

Co-authored-by: Keith Simmons <keithsim@microsoft.com>
macos-click-through
Keith Simmons 3 years ago committed by GitHub
parent 8682680c79
commit 36200088a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -303,37 +303,9 @@ impl Default for ChannelMode {
} }
} }
#[derive(Debug, Default)]
pub struct ClientVersion {
pub major: u64,
pub minor: Option<u64>,
pub patch: Option<u64>,
pub prerelease: Option<String>,
pub commit: Option<String>,
}
#[derive(Debug)]
pub enum ClientType {
Remote,
Ui,
Embedder,
Host,
Plugin,
}
impl Default for ClientType {
fn default() -> Self {
Self::Remote
}
}
#[derive(Debug, Default)] #[derive(Debug, Default)]
pub struct ClientInfo { pub struct ClientInfo {
pub name: String, pub name: String,
pub version: ClientVersion,
pub client_type: ClientType,
// methods
// attributes
} }
#[derive(Debug, Default)] #[derive(Debug, Default)]
@ -964,40 +936,6 @@ pub fn parse_channel_mode(channel_mode_value: Value) -> Result<ChannelMode> {
} }
} }
pub fn parse_client_version(version_value: Value) -> Result<ClientVersion> {
let version_map = parse_map(version_value)?;
let mut version = ClientVersion::default();
for version_property in version_map {
if let (Value::String(name), value) = version_property {
match (name.as_str().unwrap(), value) {
("major", major) => version.major = parse_u64(major)?,
("minor", minor) => version.minor = Some(parse_u64(minor)?),
("patch", patch) => version.patch = Some(parse_u64(patch)?),
("prerelease", prerelease) => version.prerelease = Some(parse_string(prerelease)?),
("commit", commit) => version.commit = Some(parse_string(commit)?),
_ => debug!("Ignored client version property: {}", name),
}
} else {
debug!("Invalid client version format");
}
}
Ok(version)
}
pub fn parse_client_type(client_type_value: Value) -> Result<ClientType> {
match parse_string(client_type_value)?.as_ref() {
"remote" => Ok(ClientType::Remote),
"ui" => Ok(ClientType::Ui),
"embedder" => Ok(ClientType::Embedder),
"host" => Ok(ClientType::Host),
"plugin" => Ok(ClientType::Plugin),
client_type => Err(ParseError::Format(format!("{:?}", client_type))),
}
}
pub fn parse_client_info(client_info_value: Value) -> Result<ClientInfo> { pub fn parse_client_info(client_info_value: Value) -> Result<ClientInfo> {
let client_info_map = parse_map(client_info_value)?; let client_info_map = parse_map(client_info_value)?;
@ -1007,8 +945,6 @@ pub fn parse_client_info(client_info_value: Value) -> Result<ClientInfo> {
if let (Value::String(name), value) = info_property { if let (Value::String(name), value) = info_property {
match (name.as_str().unwrap(), value) { match (name.as_str().unwrap(), value) {
("name", name) => client_info.name = parse_string(name)?, ("name", name) => client_info.name = parse_string(name)?,
("version", version) => client_info.version = parse_client_version(version)?,
("type", client_type) => client_info.client_type = parse_client_type(client_type)?,
_ => debug!("Ignored client type property: {}", name), _ => debug!("Ignored client type property: {}", name),
} }
} else { } else {

@ -60,13 +60,14 @@ async fn start_neovim_runtime() {
} }
} }
let settings = SETTINGS.get::<CmdLineSettings>();
let mut is_remote = settings.wsl;
if let ConnectionMode::RemoteTcp(_) = connection_mode() { if let ConnectionMode::RemoteTcp(_) = connection_mode() {
setup_neovide_specific_state(&nvim, true).await; is_remote = true;
} else {
setup_neovide_specific_state(&nvim, false).await;
} }
setup_neovide_specific_state(&nvim, is_remote).await;
let settings = SETTINGS.get::<CmdLineSettings>();
let geometry = settings.geometry; let geometry = settings.geometry;
let mut options = UiAttachOptions::new(); let mut options = UiAttachOptions::new();
options.set_linegrid_external(true); options.set_linegrid_external(true);

@ -1,4 +1,4 @@
use log::info; use log::{info, warn};
use nvim_rs::Neovim; use nvim_rs::Neovim;
use rmpv::Value; use rmpv::Value;
@ -83,7 +83,7 @@ pub async fn setup_neovide_specific_state(nvim: &Neovim<TxWrapper>, is_remote: b
.ok(); .ok();
// Retrieve the channel number for communicating with neovide // Retrieve the channel number for communicating with neovide
let neovide_channel: u64 = nvim let neovide_channel: Option<u64> = nvim
.list_chans() .list_chans()
.await .await
.ok() .ok()
@ -97,36 +97,43 @@ pub async fn setup_neovide_specific_state(nvim: &Neovim<TxWrapper>, is_remote: b
} if name == "neovide" => Some(*id), } if name == "neovide" => Some(*id),
_ => None, _ => None,
}) })
}) });
.unwrap_or(0);
// Record the channel to the log if let Some(neovide_channel) = neovide_channel {
info!( // Record the channel to the log
"Neovide registered to nvim with channel id {}", info!(
neovide_channel "Neovide registered to nvim with channel id {}",
); neovide_channel
);
// Create a command for registering right click context hooking // Create a command for registering right click context hooking
#[cfg(windows)] #[cfg(windows)]
nvim.command(&build_neovide_command( nvim.command(&build_neovide_command(
neovide_channel, neovide_channel,
0, 0,
"NeovideRegisterRightClick", "NeovideRegisterRightClick",
"register_right_click", "register_right_click",
)) ))
.await .await
.ok(); .ok();
// Create a command for unregistering the right click context hooking // Create a command for unregistering the right click context hooking
#[cfg(windows)] #[cfg(windows)]
nvim.command(&build_neovide_command( nvim.command(&build_neovide_command(
neovide_channel, neovide_channel,
0, 0,
"NeovideUnregisterRightClick", "NeovideUnregisterRightClick",
"unregister_right_click", "unregister_right_click",
)) ))
.await .await
.ok(); .ok();
if is_remote {
setup_neovide_remote_clipboard(nvim, neovide_channel).await;
}
} else {
warn!("Neovide could not find the correct channel id. Some functionality may be disabled.");
}
// Set some basic rendering options // Set some basic rendering options
nvim.set_option("lazyredraw", Value::Boolean(false)) nvim.set_option("lazyredraw", Value::Boolean(false))
@ -140,10 +147,6 @@ pub async fn setup_neovide_specific_state(nvim: &Neovim<TxWrapper>, is_remote: b
nvim.command("autocmd VimLeave * call rpcnotify(1, 'neovide.quit', v:exiting)") nvim.command("autocmd VimLeave * call rpcnotify(1, 'neovide.quit', v:exiting)")
.await .await
.ok(); .ok();
if is_remote {
setup_neovide_remote_clipboard(nvim, neovide_channel).await;
}
} }
#[cfg(windows)] #[cfg(windows)]

Loading…
Cancel
Save