Skip to content

Commit

Permalink
refactor: remove else in task details formatter
Browse files Browse the repository at this point in the history
  • Loading branch information
u8slvn committed Jul 11, 2024
1 parent 445cca5 commit 5727d06
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/hyperfocus/termui/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,18 @@ def task_details(value: str | None) -> str:
return icons.EMPTY_DETAILS

lines = value.splitlines()
if len(lines) > 1:
start, *middle, end = lines

start = f"{icons.MULTILINES_DETAILS_START} {start}"
middle = [f"{icons.MULTILINES_DETAILS_MIDDLE} {line}" for line in middle]
end = f"{icons.MULTILINES_DETAILS_END} {end}"

return "\n" + "\n".join([start, *middle, end])
else:
if len(lines) <= 1:
return value

start, *middle, end = lines

start = f"{icons.MULTILINES_DETAILS_START} {start}"
middle = [f"{icons.MULTILINES_DETAILS_MIDDLE} {line}" for line in middle]
end = f"{icons.MULTILINES_DETAILS_END} {end}"

return "\n" + "\n".join([start, *middle, end])


def stashed_task(old_task_id: int, task: Task) -> str:
# TODO: find a way to merge with classic task formatter.
Expand Down

0 comments on commit 5727d06

Please sign in to comment.