This commit is contained in:
genotrance 2020-04-12 14:08:16 -05:00 • committed by GitHub
commit 35b046373a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -44,7 +44,7 @@ Options:
--color[:always] force color even if output is redirected --color[:always] force color even if output is redirected
--colorTheme:THEME select color THEME from 'simple' (default), --colorTheme:THEME select color THEME from 'simple' (default),
'bnw' (black and white) ,'ack', or 'gnu' (GNU grep) 'bnw' (black and white) ,'ack', or 'gnu' (GNU grep)
--afterContext:N, --afterContext:N,
-a:N print N lines of trailing context after every match -a:N print N lines of trailing context after every match
--beforeContext:N, --beforeContext:N,
-b:N print N lines of leading context before every match -b:N print N lines of leading context before every match
@ -412,6 +412,8 @@ proc processFile(pattern; filename: string; counter: var int, errors: var int) =
else: else:
printContextBetween(si, prevMi, curMi) printContextBetween(si, prevMi, curMi)
printMatch(si.fileName, curMi) printMatch(si.fileName, curMi)
if t.last == buffer.len - 1:
stdout.write("\n")
stdout.flushFile() stdout.flushFile()
else: else:
let r = replace(curMi.match, pattern, replacement % matches) let r = replace(curMi.match, pattern, replacement % matches)
@ -659,8 +661,6 @@ else:
walker(rep, f, counter, errors) walker(rep, f, counter, errors)
if errors != 0: if errors != 0:
printError $errors & " errors" printError $errors & " errors"
if counter == 1:
stdout.write("\n")
stdout.write($counter & " matches\n") stdout.write($counter & " matches\n")
if errors != 0: if errors != 0:
quit(1) quit(1)