[gedit-plugins/gnome-3-16] git: Fix error when the file in git is empty



commit abf816db7d237c8eec069e874748453191a149ff
Author: Garrett Regier <garrettregier gmail com>
Date:   Mon May 18 08:06:22 2015 -0700

    git: Fix error when the file in git is empty

 plugins/git/git/viewactivatable.py |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/plugins/git/git/viewactivatable.py b/plugins/git/git/viewactivatable.py
index d370053..9b62f16 100644
--- a/plugins/git/git/viewactivatable.py
+++ b/plugins/git/git/viewactivatable.py
@@ -140,9 +140,10 @@ class GitViewActivatable(GObject.Object, Gedit.ViewActivatable):
             self.file_contents_list = file_contents.splitlines()
 
             # Remove the last empty line added by gedit automatically
-            last_item = self.file_contents_list[-1]
-            if last_item[-1:] == '\n':
-                self.file_contents_list[-1] = last_item[:-1]
+            if len(self.file_contents_list) > 0:
+                last_item = self.file_contents_list[-1]
+                if last_item[-1:] == '\n':
+                    self.file_contents_list[-1] = last_item[:-1]
 
         except GLib.Error:
             # New file in a git repository


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]