make _set_text_field work properly when 1 line long

OBO error resulted in the new text getting appended rather than
replacing the existing text in this case.
This commit is contained in:
Soren I. Bjornstad 2021-09-21 10:24:28 -05:00
parent c91e507a89
commit 87438e5858

View File

@ -461,7 +461,7 @@ def _set_text_field(mappings: Dict[str, str]) -> None:
def editor(tiddler_path: Path, tiddler_lines: Sequence[str], new_text: str) -> None: def editor(tiddler_path: Path, tiddler_lines: Sequence[str], new_text: str) -> None:
if not str(tiddler_path).endswith('.tid'): if not str(tiddler_path).endswith('.tid'):
# will be a separate meta file, so the whole thing is the text field # will be a separate meta file, so the whole thing is the text field
first_blank_line_index = 0 first_blank_line_index = -1
else: else:
first_blank_line_index = next(idx first_blank_line_index = next(idx
for idx, value in enumerate(tiddler_lines) for idx, value in enumerate(tiddler_lines)