Skip to content

Commit

Permalink
fix span bounds in lsp
Browse files Browse the repository at this point in the history
  • Loading branch information
kaikalii committed Nov 27, 2024
1 parent c51ae0f commit 6c81263
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
7 changes: 0 additions & 7 deletions site/primitives.json
Original file line number Diff line number Diff line change
Expand Up @@ -617,13 +617,6 @@
"class": "Constant",
"description": "The number of radians in a quarter circle"
},
"eval": {
"args": 2,
"outputs": 1,
"class": "Misc",
"description": "Evalute a string as code at compile time",
"experimental": true
},
"fall": {
"glyph": "",
"args": 1,
Expand Down
6 changes: 3 additions & 3 deletions src/lex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -420,11 +420,11 @@ impl CodeSpan {
let line = line as u16;
let col = col as u16;
if self.start.line == self.end.line {
self.start.line == line && (self.start.col..=self.end.col).contains(&col)
self.start.line == line && (self.start.col..self.end.col).contains(&col)
} else {
(self.start.line..=self.end.line).contains(&line)
&& (self.start.line < line || col >= self.start.col)
&& (self.end.line > line || col <= self.end.col)
&& (self.start.line < line || col > self.start.col)
&& (self.end.line > line || col < self.end.col)
}
}
/// Get the text of the span from the inputs
Expand Down
11 changes: 10 additions & 1 deletion src/lsp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,7 @@ mod server {
let path = uri_path(&params.text_document_position_params.text_document.uri);
let (line, col) =
lsp_pos_to_uiua(params.text_document_position_params.position, &doc.input);
self.debug(&format!("Hovering at {line}:{col}")).await;
// Hovering a primitive
for sp in &doc.spans {
if sp.span.contains_line_col(line, col) && sp.span.src == path {
Expand All @@ -1034,7 +1035,15 @@ mod server {
kind: MarkupKind::Markdown,
value: full_prim_doc_markdown(prim),
}),
range: Some(uiua_span_to_lsp(&sp.span, &doc.asm.inputs)),
range: Some({
let span = uiua_span_to_lsp(&sp.span, &doc.asm.inputs);
self.debug(&format!(
"Hovering {prim} at {:?}-{:?}",
span.start, span.end
))
.await;
span
}),
}));
}
SpanKind::Obverse(set_inverses) => {
Expand Down

0 comments on commit 6c81263

Please sign in to comment.