Skip to content

Commit

Permalink
fix type errors missing from +page.svelte file
Browse files Browse the repository at this point in the history
  • Loading branch information
nkitsaini committed Feb 17, 2024
1 parent 7a53512 commit c0a5ba8
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions helix-lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,4 @@ thiserror = "1.0"
tokio = { version = "1.35", features = ["rt", "rt-multi-thread", "io-util", "io-std", "time", "process", "macros", "fs", "parking_lot", "sync"] }
tokio-stream = "0.1.14"
parking_lot = "0.12.1"
percent-encoding = "2.3.1"
6 changes: 5 additions & 1 deletion helix-lsp/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ mod transport;

pub use client::Client;
pub mod copilot_types;
mod uri_deserializer;
pub use futures_executor::block_on;
pub use jsonrpc::Call;
pub use lsp::{Position, Url};
Expand All @@ -28,6 +29,8 @@ use std::{
use thiserror::Error;
use tokio_stream::wrappers::UnboundedReceiverStream;

use crate::uri_deserializer::to_percent_decode_url;

pub type Result<T> = core::result::Result<T, Error>;
pub type LanguageServerName = String;

Expand Down Expand Up @@ -613,7 +616,8 @@ impl Notification {
lsp::notification::Initialized::METHOD => Self::Initialized,
lsp::notification::Exit::METHOD => Self::Exit,
lsp::notification::PublishDiagnostics::METHOD => {
let params: lsp::PublishDiagnosticsParams = params.parse()?;
let mut params: lsp::PublishDiagnosticsParams = params.parse()?;
params.uri = to_percent_decode_url(&params.uri);
Self::PublishDiagnostics(params)
}

Expand Down
39 changes: 39 additions & 0 deletions helix-lsp/src/uri_deserializer.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
use lsp_types::Url;
use std::fmt;

use serde::de::{self, Visitor};

pub struct LspUriVisitor;

impl<'de> Visitor<'de> for LspUriVisitor {
type Value = lsp_types::Url;

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
formatter.write_str("an uri")
}

fn visit_str<E>(self, v: &str) -> Result<Self::Value, E>
where
E: de::Error,
{
return lsp_types::Url::parse(&std::borrow::Cow::into_owned(
percent_encoding::percent_decode_str(v).decode_utf8_lossy(),
))
.map_err(|e| E::custom(e));
}

// Similar for other methods:
// - visit_i16
// - visit_u8
// - visit_u16
// - visit_u32
// - visit_u64
}

// Stopgap until: https://github.com/gluon-lang/lsp-types/issues/276
pub fn to_percent_decode_url(url: &Url) -> Url {
return Url::parse(&std::borrow::Cow::into_owned(
percent_encoding::percent_decode_str(url.as_str()).decode_utf8_lossy(),
))
.expect("[Custom code]: failed to re-encode percent_decoded uri");
}
1 change: 1 addition & 0 deletions helix-term/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ serde = { version = "1.0", features = ["derive"] }
# ripgrep for global search
grep-regex = "0.1.12"
grep-searcher = "0.1.13"
percent-encoding = "2.3.1"

[target.'cfg(not(windows))'.dependencies] # https://github.com/vorner/signal-hook/issues/100
signal-hook-tokio = { version = "0.3", features = ["futures-v0_3"] }
Expand Down

0 comments on commit c0a5ba8

Please sign in to comment.