diff options
author | Zach Berwaldt <zberwaldt@tutamail.com> | 2025-02-13 20:59:08 -0500 |
---|---|---|
committer | Zach Berwaldt <zberwaldt@tutamail.com> | 2025-02-13 20:59:08 -0500 |
commit | 83e091e7c5eefec6bd6c9001cbc35a6fb75895f7 (patch) | |
tree | a43d9f95ab85090f2d7d4968da5a40a6109c5469 | |
parent | 0fea88ad9689d0816f5ba8e261e8b08ae4e2bf11 (diff) |
update organize notes command to close and reopen the active note.
-rw-r--r-- | note_tools/commands.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/note_tools/commands.py b/note_tools/commands.py index 3c26915..755bd5d 100644 --- a/note_tools/commands.py +++ b/note_tools/commands.py | |||
@@ -2,6 +2,7 @@ import sublime | |||
2 | import sublime_plugin | 2 | import sublime_plugin |
3 | import datetime | 3 | import datetime |
4 | import os | 4 | import os |
5 | import sys | ||
5 | from pathlib import Path | 6 | from pathlib import Path |
6 | from typing import List, Optional, Tuple | 7 | from typing import List, Optional, Tuple |
7 | 8 | ||
@@ -15,6 +16,11 @@ class OrganizeNotesCommand(sublime_plugin.WindowCommand): | |||
15 | 16 | ||
16 | notes_path = None | 17 | notes_path = None |
17 | 18 | ||
19 | active_sheet = self.window.active_sheet() | ||
20 | |||
21 | # Close the active note right away | ||
22 | active_sheet.close() | ||
23 | |||
18 | if project_data and "folders" in project_data: | 24 | if project_data and "folders" in project_data: |
19 | for folder in project_data['folders']: | 25 | for folder in project_data['folders']: |
20 | folder_path = folder['path'] | 26 | folder_path = folder['path'] |
@@ -30,7 +36,8 @@ class OrganizeNotesCommand(sublime_plugin.WindowCommand): | |||
30 | dirs = os.path.join(notes_path, year, month) | 36 | dirs = os.path.join(notes_path, year, month) |
31 | os.makedirs(dirs, exist_ok=True) | 37 | os.makedirs(dirs, exist_ok=True) |
32 | new_note = os.path.join(notes_path, year, month, note.name) | 38 | new_note = os.path.join(notes_path, year, month, note.name) |
33 | os.rename(note.resolve(), new_note) | 39 | os.rename(note.resolve(), new_note) |
40 | new_view = self.window.open_file(new_note) | ||
34 | else: | 41 | else: |
35 | sublime.message_dialog("No 'Notes' directory found in the project. Please add a 'Notes' folder.") | 42 | sublime.message_dialog("No 'Notes' directory found in the project. Please add a 'Notes' folder.") |
36 | 43 | ||