Skip to content

Commit

Permalink
Add back normalize_prefix()
Browse files Browse the repository at this point in the history
  • Loading branch information
jsh9 committed Jan 7, 2024
1 parent 72b1885 commit 714be7f
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/cercis/linegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,24 @@ def append_to_line(leaf: Leaf) -> Iterator[Line]:
yield current_line


def normalize_prefix(leaf: Leaf, *, inside_brackets: bool) -> None:
"""Leave existing extra newlines if not `inside_brackets`. Remove everything
else.
Note: don't use backslashes for formatting or you'll lose your voting rights.
"""
if not inside_brackets:
spl = leaf.prefix.split("#")
if "\\" not in spl[0]:
nl_count = spl[-1].count("\n")
if len(spl) > 1:
nl_count -= 1
leaf.prefix = "\n" * nl_count
return

leaf.prefix = ""


def normalize_invisible_parens( # noqa: C901
node: Node,
parens_after: Set[str],
Expand Down

0 comments on commit 714be7f

Please sign in to comment.