Fixed replacement mode.
h3rald h3rald@h3rald.com
Sat, 11 Jun 2016 22:36:13 +0200
1 files changed,
2 insertions(+),
3 deletions(-)
jump to
M
far.nim
→
far.nim
@@ -180,7 +180,6 @@ var file: File
if not file.open(f): raise newException(IOError, "Unable to open file '$1'" % f) while file.readline(contents): - hasSubstitutions = false lineN.inc contentsLen = contents.len fileLines.add contents@@ -200,7 +199,7 @@ offset = substitute.len-(matchend-matchstart+1)
for i in 0..(f.len+1): stdout.write(" ") displayMatch(replacement, matchstart, matchend+offset, fgYellow, lineN) - if (options.apply or confirm("Confirm replacement? [Y/n] ")): + if (options.apply or confirm("Confirm replacement? [y/n] ")): hasSubstitutions = true subsN.inc contents = replacement@@ -210,7 +209,7 @@ displayFile(f, silent = options.silent)
displayMatch(contents, match[0], match[1], fgYellow, lineN, silent = options.silent) match = matchBounds(contents, options.regex, matchend+offset+1, flags = options.flags) file.close() - if (not options.test) and (options.substitute != nil) and hasSubstitutions: + if (not options.test) and (not options.substitute.isNil) and hasSubstitutions: f.writefile(fileLines.join("\n")) return [matchesN, subsN]