Skip to content

Commit

Permalink
fix: decode uri
Browse files Browse the repository at this point in the history
closes #14
  • Loading branch information
xhyrom committed Oct 15, 2024
1 parent 917a011 commit 3f4d883
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
7 changes: 7 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 lsp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ git2 = { version = "0.19.0", default-features = false }
serde_json = { version = "1.0.122", features = ["std"] }
lazy_static = "1.5.0"
regex = { version = "1.10.6", default-features = false, features = ["std", "perf", "unicode-case"] }
urlencoding = "2.1.3"
16 changes: 13 additions & 3 deletions lsp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ impl Document {
}
}

fn get_filename(&self) -> &str {
self.path.file_name().unwrap().to_str().unwrap()
fn get_filename(&self) -> String {
let filename = self.path.file_name().unwrap().to_str().unwrap();
let filename = urlencoding::decode(filename).unwrap();

filename.to_string()
}

fn get_extension(&self) -> &str {
Expand Down Expand Up @@ -218,8 +221,15 @@ impl LanguageServer for Backend {
}

async fn did_open(&self, params: DidOpenTextDocumentParams) {
self.on_change(Document::new(params.text_document.uri))
let doc = Document::new(params.text_document.uri);
self.client
.log_message(
MessageType::INFO,
format!("Discord Presence LL OPEN! {}", doc.get_filename()),
)
.await;

self.on_change(doc).await;
}

async fn did_change(&self, params: DidChangeTextDocumentParams) {
Expand Down
4 changes: 2 additions & 2 deletions lsp/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ macro_rules! replace_with_capitalization {
}

pub struct Placeholders<'a> {
filename: &'a str,
filename: String,
workspace: &'a str,
language: String,
base_icons_url: &'a str,
Expand All @@ -32,7 +32,7 @@ impl<'a> Placeholders<'a> {
pub fn replace(&self, text: &str) -> String {
replace_with_capitalization!(
text,
"filename" => self.filename,
"filename" => self.filename.as_str(),
"workspace" => self.workspace,
"language" => self.language.as_str(),
"base_icons_url" => self.base_icons_url
Expand Down

0 comments on commit 3f4d883

Please sign in to comment.