about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authornfnty <git@nfnty.se>2015-12-28 11:27:35 +0100
committernfnty <git@nfnty.se>2016-02-08 04:43:04 +0100
commit69ac2c873254f82669471254ee6b174237957738 (patch)
tree48202f2bf56de6524a9171b90c837efc50701907
parente7cde84822cf990501e2fbba60e3109829af7aa2 (diff)
downloadranger-69ac2c873254f82669471254ee6b174237957738.tar.gz
VCS: Fix browsercolumn
-rw-r--r--ranger/ext/vcs/vcs.py15
-rw-r--r--ranger/gui/widgets/__init__.py28
-rw-r--r--ranger/gui/widgets/browsercolumn.py14
3 files changed, 33 insertions, 24 deletions
diff --git a/ranger/ext/vcs/vcs.py b/ranger/ext/vcs/vcs.py
index b4009d62..d70af92d 100644
--- a/ranger/ext/vcs/vcs.py
+++ b/ranger/ext/vcs/vcs.py
@@ -354,14 +354,18 @@ class Vcs(object):
 def init_subroots(dirobj):
     """Initialize roots under dirobj"""
     redraw = False
+    has_vcschild = False
+
     for fileobj in dirobj.files_all:
         if not fileobj.is_directory or not fileobj.vcs or not fileobj.vcs.track:
             continue
-        if fileobj.vcs.is_root and not fileobj.vcs.rootinit:
-            if fileobj.vcs.init_root():
-                redraw = True
+        if fileobj.vcs.is_root:
+            has_vcschild = True
+            if not fileobj.vcs.rootinit:
+                fileobj.vcs.init_root()
         elif fileobj.is_link:
             if os.path.realpath(fileobj.path) == fileobj.vcs.root:
+                has_vcschild = True
                 if not fileobj.vcs.rootvcs.rootinit:
                     fileobj.vcs.rootvcs.init_root()
                 fileobj.vcsstatus = fileobj.vcs.rootvcs.obj.vcsstatus
@@ -370,6 +374,11 @@ def init_subroots(dirobj):
                 fileobj.vcsstatus = fileobj.vcs.rootvcs.status_subpath(
                     os.path.realpath(fileobj.path))
             redraw = True
+
+    if dirobj.has_vcschild != has_vcschild:
+        redraw = True
+        dirobj.has_vcschild = has_vcschild
+
     return redraw
 
 class VcsThread(threading.Thread):
diff --git a/ranger/gui/widgets/__init__.py b/ranger/gui/widgets/__init__.py
index ca3e90ce..f61e18eb 100644
--- a/ranger/gui/widgets/__init__.py
+++ b/ranger/gui/widgets/__init__.py
@@ -6,24 +6,24 @@ class Widget(Displayable):
     """A class for classification of widgets."""
 
     vcsstatus_symb = {
-        'conflict':  ('X', ["vcsconflict"]),
-        'untracked': ('+', ["vcschanged"]),
-        'deleted':   ('-', ["vcschanged"]),
-        'changed':   ('*', ["vcschanged"]),
-        'staged':    ('*', ["vcsstaged"]),
-        'ignored':   ('·', ["vcsignored"]),
-        'sync':      ('√', ["vcssync"]),
+        'conflict':  ('X', ['vcsconflict']),
+        'untracked': ('+', ['vcschanged']),
+        'deleted':   ('-', ['vcschanged']),
+        'changed':   ('*', ['vcschanged']),
+        'staged':    ('*', ['vcsstaged']),
+        'ignored':   ('·', ['vcsignored']),
+        'sync':      ('√', ['vcssync']),
         'none':      (' ', []),
-        'unknown':   ('?', ["vcsunknown"]),
+        'unknown':   ('?', ['vcsunknown']),
     }
 
     vcsremotestatus_symb = {
-        'diverged': ('Y', ["vcsdiverged"]),
-        'ahead':    ('>', ["vcsahead"]),
-        'behind':   ('<', ["vcsbehind"]),
-        'sync':     ('=', ["vcssync"]),
-        'none':     ('⌂', ["vcsnone"]),
-        'unknown':  ('?', ["vcsunknown"]),
+        'diverged': ('Y', ['vcsdiverged']),
+        'ahead':    ('>', ['vcsahead']),
+        'behind':   ('<', ['vcsbehind']),
+        'sync':     ('=', ['vcssync']),
+        'none':     ('⌂', ['vcsnone']),
+        'unknown':  ('?', ['vcsunknown']),
     }
 
     ellipsis = {False: '~', True: '…'}
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 944f5c58..07830b31 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -257,7 +257,7 @@ class BrowserColumn(Pager):
             metakey = hash(repr(sorted(metadata.items()))) if metadata else 0
             key = (self.wid, selected_i == i, drawn.marked, self.main_column,
                    drawn.path in copied, tagged_marker, drawn.infostring,
-                   drawn.vcsstatus, drawn.vcsremotestatus,
+                   drawn.vcsstatus, drawn.vcsremotestatus, self.target.has_vcschild,
                    self.fm.do_cut, current_linemode.name, metakey)
 
             if key in drawn.display_data:
@@ -372,20 +372,20 @@ class BrowserColumn(Pager):
 
     def _draw_vcsstring_display(self, drawn):
         vcsstring_display = []
-        directory = drawn if drawn.is_directory else self.target
-        if directory.vcs and directory.vcs.track:
+        if (self.target.vcs and self.target.vcs.track) \
+                or (drawn.is_directory and drawn.vcs and drawn.vcs.track):
             if drawn.vcsremotestatus:
                 vcsstr, vcscol = self.vcsremotestatus_symb[drawn.vcsremotestatus]
                 vcsstring_display.append([vcsstr, ['vcsremote'] + vcscol])
             elif self.target.has_vcschild:
-                vcsstring_display.insert(-1, [" ", []])
+                vcsstring_display.append([' ', []])
             if drawn.vcsstatus:
                 vcsstr, vcscol = self.vcsstatus_symb[drawn.vcsstatus]
                 vcsstring_display.append([vcsstr, ['vcsfile'] + vcscol])
-            else:
-                vcsstring_display.append([" ", []])
+            elif self.target.has_vcschild:
+                vcsstring_display.append([' ', []])
         elif self.target.has_vcschild:
-            vcsstring_display.append(["  ", []])
+            vcsstring_display.append(['  ', []])
 
         return vcsstring_display