From 5dfb4c137a7e0d86340d716a6edce7badc8d6d49 Mon Sep 17 00:00:00 2001 From: Dianyi Yang Date: Tue, 15 Oct 2024 19:59:19 -0400 Subject: [PATCH 1/2] Fix broken output pane caused by lines with hashtags only --- crates/ark/src/lsp/symbols.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/crates/ark/src/lsp/symbols.rs b/crates/ark/src/lsp/symbols.rs index 3f9ed7588..b4c4e4dec 100644 --- a/crates/ark/src/lsp/symbols.rs +++ b/crates/ark/src/lsp/symbols.rs @@ -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 } From 945fa01da65a2dc85906b742bf672d24f3038e56 Mon Sep 17 00:00:00 2001 From: Dianyi Yang Date: Wed, 16 Oct 2024 07:09:09 -0400 Subject: [PATCH 2/2] Add tests for hastag-only comment lines --- crates/ark/src/lsp/symbols.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ark/src/lsp/symbols.rs b/crates/ark/src/lsp/symbols.rs index b4c4e4dec..264bb7b2b 100644 --- a/crates/ark/src/lsp/symbols.rs +++ b/crates/ark/src/lsp/symbols.rs @@ -335,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"))) @@ -345,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 {