Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev: correctly parse and show hover doc #105

Merged
merged 3 commits into from
Mar 27, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
dev: half hover
  • Loading branch information
Myriad-Dreamin committed Mar 26, 2024
commit 3cfde6a67d5edd03d23e6fe54a777321ee068cb2
15 changes: 15 additions & 0 deletions crates/tinymist-query/src/hover.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ impl DocTooltip {
// todo: import
let target = def_target.node().clone();
let mut node = def_target.node().clone();
let mut newline_count = 0;
while let Some(prev) = node.prev_sibling() {
node = prev;
if node.kind() == SyntaxKind::Hash {
Expand All @@ -231,10 +232,24 @@ impl DocTooltip {
continue;
}

log::info!("found comment node: {:?}: {:?}", n.kind(), n.text());

if n.kind() == SyntaxKind::Hash {
newline_count = 0;
continue;
}
if n.kind() == SyntaxKind::Space {
if n.text().contains('\n') {
newline_count += 1;
}
if newline_count > 1 {
break;
}
continue;
}
newline_count = 0;
if n.kind() == SyntaxKind::LineComment {
newline_count = 1;
// comments.push(n.text().strip_prefix("//")?.trim().to_owned());
// strip all slash prefix
let text = n.text().trim_start_matches('/');
Expand Down
Loading