Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ IndentFunctionDeclarationAfterType: false
IndentWidth: 4
IndentWrappedFunctionNames: false
IndentRequiresClause: true
InsertNewlineAtEOF: true
RequiresClausePosition: OwnLine
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
Expand Down
11 changes: 10 additions & 1 deletion pre-commit-hooks/json_in_cpp.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,13 @@ def replace_json(match):


def fix_indentation(cpp_content: str) -> str:
if "JSON(" not in cpp_content:
return cpp_content

lines = cpp_content.splitlines()

ends_with_newline = cpp_content.endswith('\n')

def find_indentation(line: str) -> int:
return len(line) - len(line.lstrip())

Expand All @@ -66,7 +71,11 @@ def find_indentation(line: str) -> int:
break
lines[i] = lines[i][by_how_much:] if by_how_much > 0 else " " * (-by_how_much) + lines[i]

return "\n".join(lines) + "\n"
result = "\n".join(lines)

if ends_with_newline:
result += "\n"
return result


def process_file(file_path: Path, dry_run: bool) -> bool:
Expand Down