Skip to content

Commit

Permalink
Revert "Support legacy workspace root"
Browse files Browse the repository at this point in the history
This reverts commit d29a162.
  • Loading branch information
alopatindev committed Nov 14, 2023
1 parent d29a162 commit 08233b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
16 changes: 6 additions & 10 deletions src/bin/_cargo-limit-open-in-nvim.rs
Expand Up @@ -8,7 +8,6 @@ use std::{

struct NeovimCommand {
escaped_workspace_root: String,
legacy_escaped_workspace_root: String,
command: String,
}

Expand All @@ -21,24 +20,21 @@ impl NeovimCommand {

let editor_data: EditorData = serde_json::from_str(&raw_editor_data)?;
let escaped_workspace_root = editor_data.escaped_workspace_root();
let legacy_escaped_workspace_root = editor_data.legacy_escaped_workspace_root();

Ok(Some(Self {
escaped_workspace_root,
legacy_escaped_workspace_root,
command,
}))
}

fn run(self) -> Result<ExitStatus> {
// TODO: exit code?
self.run_inner(&self.legacy_escaped_workspace_root)?;
self.run_inner(&self.escaped_workspace_root)
}
let NeovimCommand {
escaped_workspace_root,
command,
} = self;

fn run_inner(&self, escaped_workspace_root: &str) -> Result<ExitStatus> {
let server_name = nvim_listen_address(escaped_workspace_root)?;
let remote_send_args = vec!["--server", &server_name, "--remote-send", &self.command];
let remote_send_args = vec!["--server", &server_name, "--remote-send", &command];

match Command::new("nvim").args(remote_send_args).output() {
Ok(Output {
Expand All @@ -65,7 +61,7 @@ impl NeovimCommand {
}
}

fn nvim_listen_address(escaped_workspace_root: &str) -> Result<String> {
fn nvim_listen_address(escaped_workspace_root: String) -> Result<String> {
const PREFIX: &str = "nvim-cargo-limit-";

let result = {
Expand Down
11 changes: 2 additions & 9 deletions src/models.rs
Expand Up @@ -29,17 +29,10 @@ impl EditorData {
}

pub fn escaped_workspace_root(&self) -> String {
self.escaped_workspace_root_inner("@")
}

pub fn legacy_escaped_workspace_root(&self) -> String {
self.escaped_workspace_root_inner("%")
}

fn escaped_workspace_root_inner(&self, escape_char: &str) -> String {
const ESCAPE_CHAR: &str = "@";
self.workspace_root
.to_string_lossy()
.replace(['/', '\\', ':'], escape_char)
.replace(['/', '\\', ':'], ESCAPE_CHAR)
}
}

Expand Down

0 comments on commit 08233b7

Please sign in to comment.