Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save task before closing editor #1175

Merged
merged 1 commit into from
Feb 12, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions GTG/gtk/editor/editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, app, task):

self.app = app
self.ds = app.ds
self.task = task
self.task: Task = task
self.config = app.config_core
self.task_config = self.config.get_task_config(str(task.id))
self.time = None
Expand Down Expand Up @@ -778,7 +778,7 @@ def save(self):
self.time = time.time()


# light_save save the task without refreshing every 30seconds
# light_save save the task without refreshing every 30 seconds
# We will reduce the time when the get_text will be in another thread

def light_save(self):
Expand Down Expand Up @@ -836,13 +836,16 @@ def destruction(self, _=None):
# process textview to make sure every tag is parsed
self.textview.process()

# Save should be also called when buffer is modified
# Save because self.textview.process() only calls light_save(), which
# isn't guaranteed to actually save (see #1138)
self.save()

# self.pengine.onTaskClose(self.plugin_api)
# self.pengine.remove_api(self.plugin_api)

tid = self.task.id

if self.is_new():
if self.task.is_new():
self.app.ds.tasks.remove(tid)
else:
self.save()
Expand Down
3 changes: 2 additions & 1 deletion GTG/gtk/editor/taskview.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ def process(self,mask_current_word:bool=False) -> None:

if not self.buffer.props.text:
# Why process if there's nothing to process
log.warning('No text to process')
return

log.debug('Processing text buffer after %dms', self.PROCESSING_DELAY)
Expand Down Expand Up @@ -266,7 +267,7 @@ def process(self,mask_current_word:bool=False) -> None:
self.detect_url(text, start)
self.detect_internal_link(text, start)

# remove current word from the text befor looking for tags
# remove current word from the text before looking for tags
if mask_current_word and cursor_line==start.get_line():
cur_pos = cursor_iter.get_line_offset()
text = TaskView.mask_current_word(text,cur_pos)
Expand Down