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

Fix broken output pane caused by lines with hashtags only #590

Merged
merged 3 commits into from
Oct 17, 2024
Merged
Changes from all commits
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
5 changes: 5 additions & 0 deletions crates/ark/src/lsp/symbols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ fn parse_comment_as_section(comment: &str) -> Option<(usize, String)> {
if let Some(caps) = indexer::RE_COMMENT_SECTION.captures(comment) {
let hashes = caps.get(1)?.as_str().len(); // Count the number of '#'
let title = caps.get(2)?.as_str().trim().to_string(); // Extract the title text without trailing punctuations
if title.is_empty() {
return None; // Return None for lines with only hashtags
}
return Some((hashes, title)); // Return the level based on the number of '#' and the title
}

Expand Down Expand Up @@ -332,6 +335,7 @@ mod tests {
fn test_symbol_parse_comment_as_section() {
assert_eq!(parse_comment_as_section("# foo"), None);
assert_eq!(parse_comment_as_section("# foo ---"), None);
assert_eq!(parse_comment_as_section("########"), None);
assert_eq!(
parse_comment_as_section("# foo ----"),
Some((1, String::from("foo")))
Expand All @@ -342,6 +346,7 @@ mod tests {
fn test_symbol_comment_sections() {
assert_eq!(test_symbol("# foo"), vec![]);
assert_eq!(test_symbol("# foo ---"), vec![]);
assert_eq!(test_symbol("########"), vec![]);

let range = Range {
start: Position {
Expand Down
Loading