Skip to content

Commit

Permalink
Remove file read from hover code (#64)
Browse files Browse the repository at this point in the history
  • Loading branch information
WillLillis authored Feb 1, 2024
1 parent f0b6b91 commit cbe3b14
Showing 1 changed file with 35 additions and 33 deletions.
68 changes: 35 additions & 33 deletions src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,45 +213,47 @@ fn main_loop(
error: None,
};

// get the word under the cursor
let word = get_word_from_file_params(&params.text_document_position_params, "");
// treat the word under the cursor as a filename and grab it as well
let file_word = if let Some(ref doc) = curr_doc {
get_word_from_pos_params(doc, &params.text_document_position_params, ".")
let (word, file_word) = if let Some(ref doc) = curr_doc {
(
// get the word under the cursor
get_word_from_pos_params(
doc,
&params.text_document_position_params,
".",
),
// treat the word under the cursor as a filename and grab it as well
get_word_from_pos_params(
doc,
&params.text_document_position_params,
"",
),
)
} else {
""
("", "")
};

// get documentation ------------------------------------------------------
// format response
match word {
Ok(word) => {
let hover_res = get_hover_resp(
&word,
file_word,
names_to_instructions,
names_to_registers,
include_dirs,
);
match hover_res {
Some(_) => {
let result = serde_json::to_value(&hover_res).unwrap();
let result = Response {
id: id.clone(),
result: Some(result),
error: None,
};
connection.sender.send(Message::Response(result))?;
}
None => {
// don't know of this word
connection.sender.send(Message::Response(res.clone()))?;
}
}
let hover_res = get_hover_resp(
word,
file_word,
names_to_instructions,
names_to_registers,
include_dirs,
);
match hover_res {
Some(_) => {
let result = serde_json::to_value(&hover_res).unwrap();
let result = Response {
id: id.clone(),
result: Some(result),
error: None,
};
connection.sender.send(Message::Response(result))?;
}
Err(_) => {
// given word is not valid
connection.sender.send(Message::Response(res))?;
None => {
// don't know of this word
connection.sender.send(Message::Response(res.clone()))?;
}
}
} else if let Ok((id, params)) = cast_req::<Completion>(req.clone()) {
Expand Down

0 comments on commit cbe3b14

Please sign in to comment.