Refactor --lsp [SCHEME] to just take the scheme and not the ://

pull/191/head
Chip Senkbeil 12 months ago
parent ea0424e2f4
commit 31aff1e282
No known key found for this signature in database
GPG Key ID: 35EF1F8EC72A4131

@ -333,24 +333,24 @@ fn swap_prefix(obj: &mut Map<String, Value>, old: &str, new: &str) {
}
impl LspContent {
/// Converts all URIs with `file://` as the scheme to `distant://` instead
/// Converts all URIs with `file` as the scheme to `distant` instead
pub fn convert_local_scheme_to_distant(&mut self) {
self.convert_local_scheme_to("distant://")
self.convert_local_scheme_to("distant")
}
/// Converts all URIs with `file://` as the scheme to `scheme` instead
/// Converts all URIs with `file` as the scheme to `scheme` instead
pub fn convert_local_scheme_to(&mut self, scheme: &str) {
swap_prefix(&mut self.0, "file://", scheme);
swap_prefix(&mut self.0, "file:", &format!("{scheme}:"));
}
/// Converts all URIs with `distant://` as the scheme to `file://` instead
/// Converts all URIs with `distant` as the scheme to `file` instead
pub fn convert_distant_scheme_to_local(&mut self) {
self.convert_scheme_to_local("distant://")
self.convert_scheme_to_local("distant")
}
/// Converts all URIs with `scheme` as the scheme to `file://` instead
/// Converts all URIs with `scheme` as the scheme to `file` instead
pub fn convert_scheme_to_local(&mut self, scheme: &str) {
swap_prefix(&mut self.0, scheme, "file://");
swap_prefix(&mut self.0, &format!("{scheme}:"), "file:");
}
}
@ -719,7 +719,7 @@ mod tests {
"key12": true,
}));
content.convert_local_scheme_to("custom://");
content.convert_local_scheme_to("custom");
assert_eq!(
content.0,
make_obj!({
@ -809,7 +809,7 @@ mod tests {
"key12": true,
}));
content.convert_scheme_to_local("custom://");
content.convert_scheme_to_local("custom");
assert_eq!(
content.0,
make_obj!({

@ -418,11 +418,10 @@ pub enum ClientSubcommand {
network: NetworkSettings,
/// If specified, will assume the remote process is a LSP server
/// and will translate paths that are local into distant:// and vice versa.
/// and will translate paths that are local into `distant` and vice versa.
///
/// If a scheme is provided, will translate local paths into that scheme!
/// Note that the scheme must be the exact prefix like `distant://`.
#[clap(long)]
#[clap(long, name = "SCHEME")]
lsp: Option<Option<String>>,
/// If specified, will spawn process using a pseudo tty

Loading…
Cancel
Save