Skip to content

Commit

Permalink
fixed note color not being updated when renaming note.
Browse files Browse the repository at this point in the history
  • Loading branch information
fk128 committed Oct 5, 2014
1 parent a8d6c43 commit ad89354
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ def rename_note(self, index):
self.window.show_input_panel("New Name:", "", self.rename_file, None, None)

def rename_file(self, title):
global db
filename = title.split("/")
if len(filename) > 1:
title = filename[len(filename)-1]
Expand All @@ -101,11 +102,21 @@ def rename_file(self, title):
if not os.path.isfile(fname):
os.rename(self.file_path,fname)
sublime.run_command("notes_open", {"file_path": fname})

# update color scheme db
f_id = file_id(fname)
print(f_id)
if not db.get(f_id):
db[f_id] = {}
db[f_id]["color_scheme"] = db[file_id(self.file_path)]["color_scheme"]
save_to_brain()

else:
sublime.error_message("Note already exists!")
self.window.show_input_panel("New Name:", "", self.rename_file, None, None)



class NotesOpenCommand(sublime_plugin.ApplicationCommand):

def run(self, file_path):
Expand All @@ -114,7 +125,7 @@ def run(self, file_path):
def async_open(self, file_path):
view = sublime.active_window().open_file(file_path, sublime.ENCODED_POSITION)
f_id = file_id(file_path)
if db.get(f_id) and db[f_id]["color_scheme"]:
if db.get(f_id) and os.path.isfile(db[f_id]["color_scheme"]):
view.settings().set("color_scheme", db[f_id]["color_scheme"])
view.settings().set("is_note", True)

Expand Down Expand Up @@ -281,6 +292,7 @@ def plugin_loaded():
try:
gz = GzipFile(db_file, 'rb')
db = load(gz)
cleanup_brain()
gz.close()
except:
db = {}
Expand Down

0 comments on commit ad89354

Please sign in to comment.