Merge pull request #839 from gimoh/patch-1

Do not insert extra newline if line already contains it
This commit is contained in:
Brian Coca 2015-06-30 00:09:42 -04:00
commit 13116d8ac0

View file

@ -245,8 +245,11 @@ def present(module, dest, regexp, line, insertafter, insertbefore, create,
# Don't do backref expansion if not asked. # Don't do backref expansion if not asked.
new_line = line new_line = line
if lines[index[0]] != new_line + os.linesep: if not new_line.endswith(os.linesep):
lines[index[0]] = new_line + os.linesep new_line += os.linesep
if lines[index[0]] != new_line:
lines[index[0]] = new_line
msg = 'line replaced' msg = 'line replaced'
changed = True changed = True
elif backrefs: elif backrefs: