Updated search tool to dedent

This commit is contained in:
Bruce Hill 2020-02-17 12:34:42 -08:00
parent 86c477343d
commit da2955f95e

View File

@ -80,11 +80,16 @@ command line program with $args:
for $t in recursive $tree: for $t in recursive $tree:
if ($t matches $pattern_tree): if ($t matches $pattern_tree):
$line_num = ($file, line number at $t.source.start) $line_num = ($file, line number at $t.source.start)
$source = (source lines of $t)
$indent = ($source, matching "^ *")
$source = ($source, from (#$indent + 1), with "\n\$indent" -> "\n")
$results, add { $results, add {
.line = $line_num .line = $line_num
.text = (" .text = ("
\(blue "\$filename:\$line_num:") \(blue "\$filename:\$line_num:")
\(source lines of $t) \$source
") ")
} }
@ -98,4 +103,4 @@ command line program with $args:
..else: ..else:
sort $results by $ -> $.line sort $results by $ -> $.line
for $ in $results: for $ in $results:
say $.text say $.text