-
Notifications
You must be signed in to change notification settings - Fork 22
Removal of newlines before commented top-level statements #150
Copy link
Copy link
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
When a top-level statement is preceded by a comment, nufmt removes the empty line separating it from the previous block.
Minimal reproducer
# module doc
# next line comment
use b.nu [colors]
use a.nu # inline comment
use d.nu [thing]
# nex line comment
const PRIORITY_ERROR: int = 3
const PRIORITY_INFO: int = 6
const PRIORITY_INFO: int = 6
const PRIORITY_DEBUG: int = 7
# next multi
# line comment
const VOLATILE_FIELDS: list<string> = [ EXCEPTION EXCEPTION_DEBUG ]
# func comment
def level-to-max-priority [level: string]: nothing -> int {
match ($level | str upcase) {
ERROR => 3
WARNING => 4
INFO => 6
_ => 7
}
}
# func comment
def format-timestamp [ts_us: string]: nothing -> nothing { }Output:
# module doc
# next line comment
use b.nu [colors]
use a.nu # inline comment
use d.nu [thing]
# nex line comment
const PRIORITY_ERROR: int = 3
const PRIORITY_INFO: int = 6
const PRIORITY_INFO: int = 6
const PRIORITY_DEBUG: int = 7
# next multi
# line comment
const VOLATILE_FIELDS: list<string> = [EXCEPTION EXCEPTION_DEBUG]
# func comment
def level-to-max-priority [level: string]: nothing -> int {
match ($level | str upcase) {
ERROR => 3
WARNING => 4
INFO => 6
_ => 7
}
}
# func comment
def format-timestamp [ts_us: string]: nothing -> nothing { }Excepted:
# module doc
# next line comment
use b.nu [colors]
use a.nu # inline comment
use d.nu [thing]
# nex line comment
const PRIORITY_ERROR: int = 3
const PRIORITY_INFO: int = 6
const PRIORITY_INFO: int = 6
const PRIORITY_DEBUG: int = 7
# next multi
# line comment
const VOLATILE_FIELDS: list<string> = [ EXCEPTION EXCEPTION_DEBUG ]
# func comment
def level-to-max-priority [level: string]: nothing -> int {
match ($level | str upcase) {
ERROR => 3
WARNING => 4
INFO => 6
_ => 7
}
}
# func comment
def format-timestamp [ts_us: string]: nothing -> nothing { }Environment
- nushell 0.111.0
- nufmt f2f4020
- rustc 1.93.0 (254b59607 2026-01-19) (built from a source tarball)
{
indent: 2
line_length: 80
margin: 1
}Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working