Skip to content

Commit

Permalink
Fix broken output pane caused by lines with hashtags only (#590)
Browse files Browse the repository at this point in the history
  • Loading branch information
kv9898 authored Oct 17, 2024
1 parent b0101d9 commit 33100a0
Showing 1 changed file with 5 additions and 0 deletions.
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

0 comments on commit 33100a0

Please sign in to comment.