Skip to content

Commit

Permalink
fix panic when no extra spaces in layout item, but line comment in de…
Browse files Browse the repository at this point in the history
…flayer item (#16)
  • Loading branch information
rszyma authored Jan 18, 2024
1 parent eb2dbd6 commit fd7c547
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 30 deletions.
26 changes: 0 additions & 26 deletions kls/src/formatter/ext_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,32 +541,6 @@ mod tests {
}};
}

#[test]
fn test_macros() {
// use ParseTreeNode::*;
// assert_eq!(Tree!(), ExtParseTree(NodeList(vec![])));

// assert_eq!(
// Tree!(List!()),
// ExtParseTree(NodeList(vec![NodeList(vec![])]))
// );

// assert_eq!(
// Tree!(
// Atom!("test"),
// Whitespace!(" "),
// LineComment!("# test"),
// BlockComment!("#| test |#")
// ),
// ExtParseTree(NodeList(vec![
// Atom("test".to_string()),
// Whitespace(" ".to_string()),
// LineComment("# test".to_string()),
// BlockComment("#| test |#".to_string())
// ]))
// );
}

#[test]
fn test_parse_into_ext_tree() {
#[rustfmt::skip]
Expand Down
10 changes: 6 additions & 4 deletions kls/src/formatter/use_defsrc_layout_on_deflayers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,7 @@ fn collect_comments_into_metadata_vec(
Comment::LineComment(_) => {
if !is_the_last_expr_in_deflayer {
result.push(Metadata::Whitespace(
" ".repeat(
next_line_indent
.expect("line comment inside deflayer should always have newline"),
),
" ".repeat(next_line_indent.unwrap_or(0)),
));
}
}
Expand Down Expand Up @@ -403,6 +400,11 @@ mod tests {
should_not_format("(defsrc 1 2 \n 3) (deflayer base 4 5 \n 6)");
// and also with line comment
should_not_format("(defsrc 1 2 \n 3) (deflayer base 4 5 ;;\n 6)");
// https://github.com/rszyma/vscode-kanata/issues/15
formats_correctly(
"(defsrc\n a b c\n)\n(deflayer base\n a b ;;\n c\n)",
"(defsrc\n a b c\n)\n(deflayer base\n a b ;;\nc\n)",
);
}

#[test]
Expand Down

0 comments on commit fd7c547

Please sign in to comment.