Skip to content

Commit

Permalink
Sidebar fix
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuacheng committed Apr 21, 2020
1 parent 606232b commit 31d58e1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 8 additions & 4 deletions lib/SoftwareTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@
NO_ID = 'NO_ID'
CODETIME_TREEVIEW_NAME = 'Code Time Tree View'
REMOTE_URL = None
shouldOpen = True
shouldOpen = False
phantom_set = None
mainSections = ['code-time-actions', 'activity-metrics', 'contributors-node']

def setShouldOpen(val):
Expand Down Expand Up @@ -65,6 +66,7 @@ def run(self):

global tree_view
global orig_layout
global phantom_set
self.currentKeystrokeStats = SessionSummary()
window = self.window

Expand All @@ -79,7 +81,7 @@ def run(self):
window.set_layout(layout)
self.build_tree_layout()

self.phantom_set = sublime.PhantomSet(tree_view, 'software_tree')
phantom_set = sublime.PhantomSet(tree_view, 'software_tree')

if len(window.views()) == 1:
window.focus_group(1)
Expand Down Expand Up @@ -161,13 +163,14 @@ def run(self):
self.buildMetricsNodes(data)
# self.buildCommitTreeNodes()
self.buildContributorNodes()
# print(len(self.tree['childs']))
self.expand(self.tree, '')

def build_tree_layout(self):
global tree_view
global orig_layout
window = self.window
window.set_sidebar_visible(False)
# window.set_sidebar_visible(False)
layout = window.get_layout()
orig_layout = deepcopy(layout)
if len(layout['cols']) < 3:
Expand Down Expand Up @@ -272,6 +275,7 @@ def on_click(self, url):
Sublime's "minihtml" engine has some large restrictions
'''
def rebuild_phantom(self):
global phantom_set
result = self.render_subtree(self.tree, [])
html = '''<body id="tree">
<style>
Expand Down Expand Up @@ -303,7 +307,7 @@ def rebuild_phantom(self):
}
</style>''' + ''.join(result) + '</body>'
self.phantom = sublime.Phantom(sublime.Region(0), html, sublime.LAYOUT_BLOCK, on_navigate=self.on_click)
self.phantom_set.update([self.phantom])
phantom_set.update([self.phantom])

def render_subtree(self, item, result):
if 'id' in item and item['id'] in open_state:
Expand Down
3 changes: 2 additions & 1 deletion lib/SoftwareUtil.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from threading import Thread, Timer, Event, Lock
from threading import Thread, Timer, Event, Lock, current_thread
import os
import json
import time as timeModule
Expand Down Expand Up @@ -134,6 +134,7 @@ def setItem(key, value):

def refreshTreeView():
buildTreeLock.acquire()
# print('thread {} refreshing'.format(current_thread().ident))
sublime.active_window().run_command('open_tree_view')
buildTreeLock.release()

Expand Down

0 comments on commit 31d58e1

Please sign in to comment.