From b939719fe6da77779af66dbc70e775a396ef5a00 Mon Sep 17 00:00:00 2001 From: Chiel ten Brinke Date: Mon, 15 Feb 2016 09:50:41 +0100 Subject: [PATCH] Fix IndexError for when stdout and stderr of formatter are empty. --- plugin/autoformat.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugin/autoformat.vim b/plugin/autoformat.vim index e33a419..3f99557 100644 --- a/plugin/autoformat.vim +++ b/plugin/autoformat.vim @@ -181,7 +181,7 @@ else: # However, extra newlines are almost never required, while there are linters that complain # about superfluous newlines, so we remove one empty newline at the end of the file. for eol in possible_eols: - if stdoutdata[-1] == eol: + if len(stdoutdata) > 0 and stdoutdata[-1] == eol: stdoutdata = stdoutdata[:-1] lines = [stdoutdata] @@ -231,7 +231,7 @@ else: # However, extra newlines are almost never required, while there are linters that complain # about superfluous newlines, so we remove one empty newline at the end of the file. for eol in possible_eols: - if stdoutdata[-1] == eol: + if len(stdoutdata) > 0 and stdoutdata[-1] == eol: stdoutdata = stdoutdata[:-1] lines = [stdoutdata]