mirror of
https://github.com/tbabej/taskwiki.git
synced 2025-08-18 21:33:07 +02:00
Fixed bug that cursor reset when after TaskWikiBufferSave/Load
This commit is contained in:
parent
406041c868
commit
75305ed33f
2 changed files with 15 additions and 0 deletions
12
taskwiki/decorators.py
Normal file
12
taskwiki/decorators.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import vim # pylint: disable=F0401
|
||||
|
||||
def hold_vim_cursor(original_function):
|
||||
"""
|
||||
Decorator that wrap around to save cursor position and restore it
|
||||
"""
|
||||
|
||||
def wrapped_function(*args, **kwargs):
|
||||
vim.command('let save_pos = getpos(".")')
|
||||
original_function(*args, **kwargs)
|
||||
vim.command('call setpos(".", save_pos)')
|
||||
return wrapped_function
|
|
@ -16,6 +16,7 @@ from taskwiki import cache as cache_module
|
|||
from taskwiki import sort
|
||||
from taskwiki import util
|
||||
from taskwiki import viewport
|
||||
from taskwiki import decorators
|
||||
|
||||
|
||||
cache = cache_module.CacheRegistry()
|
||||
|
@ -25,6 +26,7 @@ cache.load_current()
|
|||
class WholeBuffer(object):
|
||||
@staticmethod
|
||||
@errors.pretty_exception_handler
|
||||
@decorators.hold_vim_cursor
|
||||
def update_from_tw():
|
||||
"""
|
||||
Updates all the incomplete tasks in the vimwiki file if the info from TW is different.
|
||||
|
@ -42,6 +44,7 @@ class WholeBuffer(object):
|
|||
|
||||
@staticmethod
|
||||
@errors.pretty_exception_handler
|
||||
@decorators.hold_vim_cursor
|
||||
def update_to_tw():
|
||||
"""
|
||||
Updates all tasks that differ from their TaskWarrior representation.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue