From 2553a33ba47115450b7dbfeb5b0e35ad2a46f7f0 Mon Sep 17 00:00:00 2001 From: Randy Lai Date: Mon, 19 Mar 2018 09:43:07 -0400 Subject: [PATCH] Fix: use the decoded output --- core/git_command.py | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/core/git_command.py b/core/git_command.py index 51f8bc63e..558d3b8d2 100755 --- a/core/git_command.py +++ b/core/git_command.py @@ -10,7 +10,6 @@ import subprocess import shutil import re -from contextlib import contextmanager import threading import sublime @@ -195,31 +194,38 @@ def git(self, *args, env=environ, startupinfo=startupinfo) - original_stdin = stdin - if stdin is not None and encode: - stdin = stdin.encode(encoding=stdin_encoding) - - if show_panel and live_panel_output: + def initialize_panel(): + # clear panel util.log.panel("") if savvy_settings.get("show_stdin_in_output") and stdin is not None: - util.log.panel_append("STDIN\n{}\n".format(original_stdin)) + util.log.panel_append("STDIN\n{}\n".format(stdin)) if savvy_settings.get("show_input_in_output"): - util.log.panel_append("> {}\n\n".format(command_str)) + util.log.panel_append("> {}\n".format(command_str)) + + if show_panel and live_panel_output: wrapper = LoggingProcessWrapper(p) + initialize_panel() + + if stdin is not None and encode: + stdin = stdin.encode(encoding=stdin_encoding) + + if show_panel and live_panel_output: stdout, stderr = wrapper.communicate(stdin) else: stdout, stderr = p.communicate(stdin) - if show_panel: - util.log.panel("") - if savvy_settings.get("show_stdin_in_output") and stdin is not None: - util.log.panel_append("STDIN\n{}\n".format(original_stdin)) - if savvy_settings.get("show_input_in_output"): - util.log.panel_append("> {}\n".format(command_str)) - util.log.panel_append("{}\n{}".format(stdout, stderr)) if decode: stdout, stderr = self.decode_stdout(stdout, savvy_settings), stderr.decode() + if show_panel and not live_panel_output: + initialize_panel() + if stdout: + util.log.panel_append(stdout) + if stderr: + if stdout: + util.log.panel_append("\n") + util.log.panel_append(stderr) + except Exception as e: # this should never be reached raise GitSavvyError("Please report this error to GitSavvy:\n\n{}".format(e))