From d34b3ada713afaa1e5ba048201b1715f708a63d3 Mon Sep 17 00:00:00 2001 From: sQu1rr Date: Sun, 17 Sep 2017 16:14:47 +0100 Subject: [PATCH] fixes #692 : multiline PS1 breaking instant mode --- thefuck/output_readers/read_log.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/thefuck/output_readers/read_log.py b/thefuck/output_readers/read_log.py index 6642650a..9262fa84 100644 --- a/thefuck/output_readers/read_log.py +++ b/thefuck/output_readers/read_log.py @@ -11,6 +11,10 @@ from .. import const, logs def _group_by_calls(log): + ps1 = os.environ['PS1'] + ps1_newlines = ps1.count('\\n') + ps1.count('\n') + ps1_counter = 0 + script_line = None lines = [] for line in log: @@ -19,10 +23,16 @@ def _group_by_calls(log): except UnicodeDecodeError: continue - if const.USER_COMMAND_MARK in line: - if script_line: + if const.USER_COMMAND_MARK in line or ps1_counter > 0: + if script_line and ps1_counter == 0: yield script_line, lines + if ps1_newlines > 0: + if ps1_counter <= 0: + ps1_counter = ps1_newlines + else: + ps1_counter -= 1 + script_line = line lines = [line] elif script_line is not None: