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)]
pub struct ClientInfo {
pub name: String,
pub version: ClientVersion,
pub client_type: ClientType,
// methods
// attributes
}
#[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> {
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 {
match (name.as_str().unwrap(), value) {
("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),
}
} 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() {
setup_neovide_specific_state(&nvim, true).await;
} else {
setup_neovide_specific_state(&nvim, false).await;
is_remote = true;
}
setup_neovide_specific_state(&nvim, is_remote).await;
let settings = SETTINGS.get::<CmdLineSettings>();
let geometry = settings.geometry;
let mut options = UiAttachOptions::new();
options.set_linegrid_external(true);

@ -1,4 +1,4 @@
use log::info;
use log::{info, warn};
use nvim_rs::Neovim;
use rmpv::Value;
@ -83,7 +83,7 @@ pub async fn setup_neovide_specific_state(nvim: &Neovim<TxWrapper>, is_remote: b
.ok();
// Retrieve the channel number for communicating with neovide
let neovide_channel: u64 = nvim
let neovide_channel: Option<u64> = nvim
.list_chans()
.await
.ok()
@ -97,36 +97,43 @@ pub async fn setup_neovide_specific_state(nvim: &Neovim<TxWrapper>, is_remote: b
} if name == "neovide" => Some(*id),
_ => None,
})
})
.unwrap_or(0);
});
// Record the channel to the log
info!(
"Neovide registered to nvim with channel id {}",
neovide_channel
);
if let Some(neovide_channel) = neovide_channel {
// Record the channel to the log
info!(
"Neovide registered to nvim with channel id {}",
neovide_channel
);
// Create a command for registering right click context hooking
#[cfg(windows)]
nvim.command(&build_neovide_command(
neovide_channel,
0,
"NeovideRegisterRightClick",
"register_right_click",
))
.await
.ok();
// Create a command for registering right click context hooking
#[cfg(windows)]
nvim.command(&build_neovide_command(
neovide_channel,
0,
"NeovideRegisterRightClick",
"register_right_click",
))
.await
.ok();
// Create a command for unregistering the right click context hooking
#[cfg(windows)]
nvim.command(&build_neovide_command(
neovide_channel,
0,
"NeovideUnregisterRightClick",
"unregister_right_click",
))
.await
.ok();
// Create a command for unregistering the right click context hooking
#[cfg(windows)]
nvim.command(&build_neovide_command(
neovide_channel,
0,
"NeovideUnregisterRightClick",
"unregister_right_click",
))
.await
.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
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)")
.await
.ok();
if is_remote {
setup_neovide_remote_clipboard(nvim, neovide_channel).await;
}
}
#[cfg(windows)]

Loading…
Cancel
Save