Skip to content

Commit 2b4a4ea

Browse files
committed
Fix relative keep alive paths
1 parent f86470b commit 2b4a4ea

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

src/zorg/runners.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
from __future__ import annotations
44

5-
from functools import partial
65
from pathlib import Path
76
import tempfile
87
from typing import Any, Iterable, Iterator, Mapping
@@ -67,11 +66,13 @@ def _add_paths_to_zdir(
6766

6867

6968
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)
7576

7677
logger.debug(
7778
"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:
8283
if cfg.keep_alive_file.stat().st_size == 0:
8384
paths = last_paths
8485
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+
)
8993
logger.debug(
9094
"Editing files specified in the keep alive file.",
9195
keep_alive_file=cfg.keep_alive_file,
@@ -95,7 +99,7 @@ def _start_vim_loop(zo_paths: Iterable[Path], cfg: EditConfig) -> None:
9599
paths = last_paths = new_paths
96100

97101
cfg.keep_alive_file.unlink()
98-
zvim(*paths).unwrap()
102+
run_vim(paths)
99103

100104

101105
def _process_vim_commands(

tests/test_edit_cmd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def test_whenKeepAliveFileContainsPaths_useThosePathsOnRestart(
102102
),
103103
call().unwrap(),
104104
call(
105-
["vim", "baz.zo", "buz.zo"],
105+
["vim", str(zettel_dir / "baz.zo"), str(zettel_dir / "buz.zo")],
106106
stdout=None,
107107
stderr=None,
108108
timeout=None,

0 commit comments

Comments
 (0)