diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-15 17:48:14 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-15 17:48:35 -0800 |
| commit | 5c9674880206f66c109adc1bedf8f786166f125f (patch) | |
| tree | 30d95a1aacd2b30f8cb060846cbe9efd09e31aca /lib/tools/format.nom | |
| parent | f6fe028f1786d7e582623fc26df916fcd05c2e31 (diff) | |
Fix for formatting indented code with the format tool.
Diffstat (limited to 'lib/tools/format.nom')
| -rwxr-xr-x | lib/tools/format.nom | 8 |
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: |
