aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2020-02-17 12:34:42 -0800
committerBruce Hill <bruce@bruce-hill.com>2020-02-17 12:34:42 -0800
commitda2955f95e968d80daddee0a2f6cf5f512160c10 (patch)
tree9fd95cb49a6e03cb35a11bbbca14bfdebe63bba8
parent86c477343d8ae84fc99014a2cc4f844e9c688b9c (diff)
Updated search tool to dedent
-rwxr-xr-xlib/tools/find.nom9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/tools/find.nom b/lib/tools/find.nom
index 3e26ef4..bfd4583 100755
--- a/lib/tools/find.nom
+++ b/lib/tools/find.nom
@@ -80,11 +80,16 @@ command line program with $args:
for $t in recursive $tree:
if ($t matches $pattern_tree):
$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 {
.line = $line_num
.text = ("
\(blue "\$filename:\$line_num:")
- \(source lines of $t)
+ \$source
")
}
@@ -98,4 +103,4 @@ command line program with $args:
..else:
sort $results by $ -> $.line
for $ in $results:
- say $.text \ No newline at end of file
+ say $.text