Skip to content

Commit

Permalink
fix spaces in file paths in lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Dec 28, 2024
1 parent 7128ef3 commit ce04ff2
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1039,8 +1039,14 @@ mod server {
return Ok(None);
};
let path = uri_path(&params.text_document_position_params.text_document.uri);
self.debug(format!("hover path: {path:?}")).await;
let (line, col) =
lsp_pos_to_uiua(params.text_document_position_params.position, &doc.input);

let srcs: std::collections::BTreeSet<_> =
doc.spans.iter().map(|sp| sp.span.src.clone()).collect();
self.debug(format!("hover srcs: {srcs:?}")).await;

// Hovering a primitive
for sp in &doc.spans {
if sp.span.contains_line_col(line, col) && sp.span.src == path {
Expand Down Expand Up @@ -2429,7 +2435,7 @@ mod server {
}

fn uri_path(uri: &Url) -> PathBuf {
let path = uri.path().replace("/c%3A", "C:");
let path = uri.path().replace("/c%3A", "C:").replace("%20", " ");
let path = PathBuf::from(path);
path.canonicalize().unwrap_or(path)
}
Expand Down

0 comments on commit ce04ff2

Please sign in to comment.