2
2
3
3
from __future__ import annotations
4
4
5
- from functools import partial
6
5
from pathlib import Path
7
6
import tempfile
8
7
from typing import Any , Iterable , Iterator , Mapping
@@ -67,11 +66,13 @@ def _add_paths_to_zdir(
67
66
68
67
69
68
def _start_vim_loop (zo_paths : Iterable [Path ], cfg : EditConfig ) -> None :
70
- zvim = partial (
71
- vimala .vim ,
72
- commands = _process_vim_commands (cfg .zettel_dir , cfg .vim_commands ),
73
- )
74
- zvim (* zo_paths ).unwrap ()
69
+ def run_vim (paths : Iterable [Path ]) -> None :
70
+ vimala .vim (
71
+ * paths ,
72
+ commands = _process_vim_commands (cfg .zettel_dir , cfg .vim_commands ),
73
+ ).unwrap ()
74
+
75
+ run_vim (zo_paths )
75
76
76
77
logger .debug (
77
78
"Vim loop will run as long as the keep alive file exists." ,
@@ -82,10 +83,13 @@ def _start_vim_loop(zo_paths: Iterable[Path], cfg: EditConfig) -> None:
82
83
if cfg .keep_alive_file .stat ().st_size == 0 :
83
84
paths = last_paths
84
85
else :
85
- new_paths = [
86
- Path (p .strip ())
87
- for p in cfg .keep_alive_file .read_text ().split ()
88
- ]
86
+ new_paths = _add_paths_to_zdir (
87
+ cfg .zettel_dir ,
88
+ [
89
+ Path (p .strip ())
90
+ for p in cfg .keep_alive_file .read_text ().split ()
91
+ ],
92
+ )
89
93
logger .debug (
90
94
"Editing files specified in the keep alive file." ,
91
95
keep_alive_file = cfg .keep_alive_file ,
@@ -95,7 +99,7 @@ def _start_vim_loop(zo_paths: Iterable[Path], cfg: EditConfig) -> None:
95
99
paths = last_paths = new_paths
96
100
97
101
cfg .keep_alive_file .unlink ()
98
- zvim ( * paths ). unwrap ( )
102
+ run_vim ( paths )
99
103
100
104
101
105
def _process_vim_commands (
0 commit comments