From 7c02d2c1da65bbccbcd7946a3967bfac63ff11a3 Mon Sep 17 00:00:00 2001 From: Pavel 'LEdoian' Turinsky Date: Mon, 4 May 2020 21:30:27 +0200 Subject: [PATCH] Rewind tmpfile and skip empty lines --- markdownrunner.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/markdownrunner.py b/markdownrunner.py index 1a8a114..463820a 100755 --- a/markdownrunner.py +++ b/markdownrunner.py @@ -139,8 +139,12 @@ def user_action(hunk: Sequence[Command], context=None) -> Sequence[Command]: import subprocess subprocess.run([editor, tmpfile.name]) # Read the file back + tmpfile.file.seek(0) new_hunk = [] for line in tmpfile.file.readlines(): + line = line.strip() + if line == '': + continue parts = line.split('\t', maxsplit=2) new_hunk.append(Command(user=parts[0],directory=parts[1],command=parts[2],context=None)) # Python has no goto for restarting, but we can recurse