mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-19 06:43:06 +02:00
Cache: Move Viewport loading into separate step
This commit is contained in:
parent
6edcd3d702
commit
86e41e7cad
2 changed files with 15 additions and 12 deletions
|
@ -174,6 +174,18 @@ class TaskCache(object):
|
|||
# Restore the old authority flag value
|
||||
self.buffer_has_authority = old_authority
|
||||
|
||||
def load_viewports(self):
|
||||
for i in range(len(vim.current.buffer)):
|
||||
port = viewport.ViewPort.from_line(i, self)
|
||||
|
||||
if port is None:
|
||||
continue
|
||||
|
||||
port.load_tasks()
|
||||
|
||||
# Save the viewport in the cache
|
||||
self.viewport_cache[i] = port
|
||||
|
||||
def update_vwtasks_in_buffer(self):
|
||||
for task in self.vimwikitask_cache.values():
|
||||
task.update_in_buffer()
|
||||
|
@ -222,20 +234,9 @@ class TaskCache(object):
|
|||
vwtask.update_from_task()
|
||||
|
||||
def evaluate_viewports(self):
|
||||
i = 0
|
||||
while i < len(vim.current.buffer):
|
||||
port = viewport.ViewPort.from_line(i, self)
|
||||
i += 1
|
||||
|
||||
if port is None:
|
||||
continue
|
||||
|
||||
port.load_tasks()
|
||||
for port in self.viewport_cache.values():
|
||||
port.sync_with_taskwarrior()
|
||||
|
||||
# Save the viewport in the cache
|
||||
self.viewport_cache[i] = port
|
||||
|
||||
def get_viewport_by_task(self, task):
|
||||
"""
|
||||
Looks for a viewport containing the given task by iterating over the cached
|
||||
|
|
|
@ -41,6 +41,7 @@ class WholeBuffer(object):
|
|||
cache.reset()
|
||||
cache.load_tasks()
|
||||
cache.load_vwtasks(buffer_has_authority=False)
|
||||
cache.load_viewports()
|
||||
cache.update_vwtasks_from_tasks()
|
||||
cache.update_vwtasks_in_buffer()
|
||||
cache.evaluate_viewports()
|
||||
|
@ -54,6 +55,7 @@ class WholeBuffer(object):
|
|||
cache.reset()
|
||||
cache.load_tasks()
|
||||
cache.load_vwtasks()
|
||||
cache.load_viewports()
|
||||
cache.save_tasks()
|
||||
cache.update_vwtasks_in_buffer()
|
||||
cache.evaluate_viewports()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue