Skip to content

Commit

Permalink
added directory creation /CollaBroText in cache folder. Added deletio…
Browse files Browse the repository at this point in the history
…n of comments.cbrt temporary file on closing of the comments display (Alt + x).
  • Loading branch information
SSKUltra committed Aug 20, 2017
1 parent f47cf17 commit c35796d
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions CollaBroText.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,14 +281,21 @@ def on_selection_modified(self, view):
class DisplayCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit, selected_thread_object):

global comment_view_obj, list_of_threads
global comment_view_obj, list_of_threads, location_of_cbrt


# sublime.status_message("view id of UI is set here: "+str(comment_view_obj))
current_thread = list_of_threads[selected_thread_object]
sum_of_chars = 0
com_list = current_thread.list_of_comments
package_directory = sublime.packages_path() + '/' + 'CollaBroText'
#package_directory = sublime.packages_path() + '/' + 'CollaBroText'

location_of_cbrt = sublime.cache_path() + '/CollaBroText'

#creates CollaBroText directory in cache_path() if it does not exist
if not os.path.exists(location_of_cbrt) :
os.makedirs(location_of_cbrt)


# for comment in reversed(com_list):
# #self.view.insert(edit, 0, "comment")
Expand All @@ -305,7 +312,7 @@ def run(self, edit, selected_thread_object):
# self.view.insert(edit, 0, "\n\n\n@" +
# comment.username + "\t" + final_timestamp)

with open(sublime.cache_path() + '/CollaBroText/comments.cbrt', 'w+') as fl :
with open(location_of_cbrt + '/comments.cbrt', 'w+') as fl :

for comment in (com_list):

Expand All @@ -325,7 +332,7 @@ def run(self, edit, selected_thread_object):
fl.write("\n" + ' ' +comment.comment_string)

#print("current view" + str(self.view))
comment_view_obj = window.open_file(sublime.cache_path() + '/CollaBroText/comments.cbrt')
comment_view_obj = window.open_file(location_of_cbrt + '/comments.cbrt')
#print("layout_view " + str(comment_view_obj))

comment_view_obj.set_read_only(True)
Expand All @@ -344,6 +351,11 @@ def run(self):
#layout_flag = False
layout_region = "0"

global location_of_cbrt

#deletes the comments.cbrt temp file from cache_path()
os.remove(location_of_cbrt + '/comments.cbrt')

self.window.focus_view(comment_view_obj)
self.window.run_command("close")

Expand Down

0 comments on commit c35796d

Please sign in to comment.