Skip to content

Commit ccf5cd2

Browse files
committed
fix eol comments in code macro inputs
1 parent bfd661d commit ccf5cd2

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

src/compile/modifier.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1656,9 +1656,8 @@ impl Compiler {
16561656
) -> UiuaResult<Node> {
16571657
let full_span = (modifier_span.clone()).merge(operands.last().unwrap().span.clone());
16581658
// Collect operands as strings
1659-
let mut operands: Vec<Sp<Word>> = (operands.into_iter())
1660-
.filter(|w| w.value.is_code())
1661-
.collect();
1659+
let mut operands: Vec<Sp<Word>> =
1660+
operands.into_iter().filter(|w| w.value.is_code()).collect();
16621661
if operands.len() == 1 {
16631662
let operand = operands.remove(0);
16641663
operands = match operand.value {

src/format.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -492,6 +492,7 @@ pub(crate) fn format_word(word: &Sp<Word>, inputs: &Inputs) -> String {
492492
eval_output_comments: false,
493493
};
494494
formatter.format_word(word, 0);
495+
formatter.resolve_eol_comments();
495496
formatter.output
496497
}
497498

@@ -557,6 +558,9 @@ impl Formatter<'_> {
557558
self.format_item(item, max_name_len, depth);
558559
}
559560
// Align end-of-line comments
561+
self.resolve_eol_comments();
562+
}
563+
fn resolve_eol_comments(&mut self) {
560564
if self.config.align_comments && !self.end_of_line_comments.is_empty() {
561565
// Group comments by consecutive lines
562566
let mut groups: Vec<(usize, Vec<EoLComment>)> = Vec::new();

0 commit comments

Comments
 (0)