Skip to content

Commit

Permalink
fix: run :edit command with nvim_cmd to escape special characters (#2056
Browse files Browse the repository at this point in the history
)

* Run :edit command with nvim_cmd to escape special characters

Fixes #1983

* Use a bit less verbose .cmd() function

* codestyle: use .into() for Value conversion instead

* codestyle: calm rustfmt

---------

Co-authored-by: ZyX <napav.spels@yandex.ru>
Co-authored-by: MultisampledNight <contact@multisamplednight.com>
  • Loading branch information
3 people committed Oct 14, 2023
1 parent 690c076 commit 999f37e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/bridge/ui_commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::sync::Arc;
use log::error;
use log::trace;

use nvim_rs::{call_args, rpc::model::IntoVal, Neovim};
use nvim_rs::{call_args, rpc::model::IntoVal, Neovim, Value};
use tokio::sync::mpsc::unbounded_channel;

#[cfg(windows)]
Expand Down Expand Up @@ -150,7 +150,16 @@ impl ParallelCommand {
nvim.ui_set_focus(true).await.expect("Focus Gained Failed")
}
ParallelCommand::FileDrop(path) => {
nvim.command(format!("e {path}").as_str()).await.ok();
nvim.cmd(
vec![
("cmd".into(), "edit".into()),
("magic".into(), vec![("file".into(), false.into())].into()),
("args".into(), vec![Value::from(path)].into()),
],
vec![],
)
.await
.ok();
}
ParallelCommand::SetBackground(background) => {
nvim.command(format!("set background={}", background).as_str())
Expand Down

0 comments on commit 999f37e

Please sign in to comment.