aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2019-01-15 17:48:14 -0800
committerBruce Hill <bruce@bruce-hill.com>2019-01-15 17:48:35 -0800
commit5c9674880206f66c109adc1bedf8f786166f125f (patch)
tree30d95a1aacd2b30f8cb060846cbe9efd09e31aca /lib
parentf6fe028f1786d7e582623fc26df916fcd05c2e31 (diff)
Fix for formatting indented code with the format tool.
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: