aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rwxr-xr-xlib/tools/format.nom8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/tools/format.nom b/lib/tools/format.nom
index eee1316..c2e6a1c 100755
--- a/lib/tools/format.nom
+++ b/lib/tools/format.nom
@@ -24,19 +24,19 @@ command line program with $args:
$file = (read file $filename)
unless $file:
fail "File does not exist: \$filename"
- $leading_indent = ($file, matching "\n*([ ]*)")
+ $leading_indent = ($file, matching "^\n*([ ]*)")
$code = (NomsuCode from ($Source $filename 1 (size of $file)) $file)
try:
$tree = ($code parsed)
..if it fails with $msg:
+ $tree = (nil)
if $args.q:
$formatted = $file
..else:
say $msg
- if ($tree and (not $formatted)):
- $formatted =
- "\$leading_indent\($tree as nomsu, text, with "\n" -> "\n\$leading_indent")"
+ if $tree:
+ $formatted = ($tree as nomsu, text, indented $leading_indent)
if $formatted:
if $args.i: