From d3cd0cc8436cf615629d0fff918adcb448ff7954 Mon Sep 17 00:00:00 2001 From: genotrance Date: Sun, 12 Apr 2020 14:08:16 -0500 Subject: [PATCH] Improve #12920 fix (#13958) (cherry picked from commit 35b046373abfae8e37d0731855b8b5b49ccbfcfc) --- tools/nimgrep.nim | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/nimgrep.nim b/tools/nimgrep.nim index 26e219330b..42b192f240 100644 --- a/tools/nimgrep.nim +++ b/tools/nimgrep.nim @@ -44,7 +44,7 @@ Options: --color[:always] force color even if output is redirected --colorTheme:THEME select color THEME from 'simple' (default), 'bnw' (black and white) ,'ack', or 'gnu' (GNU grep) - --afterContext:N, + --afterContext:N, -a:N print N lines of trailing context after every match --beforeContext:N, -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: printContextBetween(si, prevMi, curMi) printMatch(si.fileName, curMi) + if t.last == buffer.len - 1: + stdout.write("\n") stdout.flushFile() else: let r = replace(curMi.match, pattern, replacement % matches) @@ -659,8 +661,6 @@ else: walker(rep, f, counter, errors) if errors != 0: printError $errors & " errors" - if counter == 1: - stdout.write("\n") stdout.write($counter & " matches\n") if errors != 0: quit(1)