Skip to content

Commit

Permalink
fix insert title error
Browse files Browse the repository at this point in the history
  • Loading branch information
fk128 committed Jul 24, 2015
1 parent 5bfa365 commit 584951c
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NotesListCommand(sublime_plugin.ApplicationCommand):
def run(self):
exclude = set([settings().get("archive_dir"),'.brain'])
root = get_root()
self.notes_dir = os.path.expanduser(root)
self.notes_dir = root
self.file_list = find_notes(self, root, exclude)
rlist = setup_notes_list(self.file_list)
window = sublime.active_window()
Expand Down Expand Up @@ -122,9 +122,7 @@ def async_open(self, file_path):
class NotesNewCommand(sublime_plugin.ApplicationCommand):

def run(self, title=None):
root = get_root()
self.notes_dir = os.path.expanduser(root)

self.notes_dir = get_root()
self.window = sublime.active_window()
if title is None:
self.window.show_input_panel("Title", "", self.create_note, None, None)
Expand All @@ -135,7 +133,7 @@ def create_note(self, title):
filename = title.split("/")
if len(filename) > 1:
title = filename[len(filename)-1]
directory = os.path.join(self.notes_dir,filename[0])
directory = os.path.join(self.notes_dir, filename[0])
tag = filename[0]
else:
title = filename[0]
Expand Down Expand Up @@ -167,6 +165,7 @@ def insert_title(self, title, tag, view):


class NotesEvents(sublime_plugin.EventListener):

def on_load_async(self, view):
if view.settings().get("is_note") or not view.file_name():
return
Expand All @@ -178,6 +177,7 @@ def on_load_async(self, view):


class NoteInsertTitleCommand(sublime_plugin.TextCommand):

def run(self, edit, **kwargs):
if settings().get("enable_yaml"):
header = "---\n"
Expand All @@ -187,7 +187,7 @@ def run(self, edit, **kwargs):
for yaml_el in settings().get("note_yaml"):
header = header + yaml_el + ":\n"
header = header + "---\n"
self.view.insert(edit, 0, header)
self.view.insert(edit, 0, header)


class NoteChangeColorCommand(sublime_plugin.WindowCommand):
Expand Down Expand Up @@ -237,16 +237,15 @@ def is_enabled(self):
class NoteArchiveCommand(sublime_plugin.WindowCommand):

def run(self):
root = get_root()
window = sublime.active_window()
self.notes_dir = os.path.expanduser(root)
self.notes_dir = get_root()
self.archive_note()
sublime.status_message(" Note Archived.")

def archive_note(self):
file_path = self.window.active_view().file_name()
f_id = file_id(file_path)
archive_dir = os.path.join(self.notes_dir,settings().get("archive_dir"))
archive_dir = os.path.join(self.notes_dir, settings().get("archive_dir"))
new_file_path = os.path.join(archive_dir, f_id)

if not os.path.exists(archive_dir):
Expand Down Expand Up @@ -279,7 +278,6 @@ def run(self):
else:
window.show_quick_panel( ['There are no notes to unarchive.'],[])


def unarchive_note(self,index):
if index == -1:
return
Expand Down

0 comments on commit 584951c

Please sign in to comment.