Dedent inline clause bodies before writing them #84

Merged
marfavi merged 3 commits from fix/inline-clause-whitespace into main 2026-10-29 14:15:18 +01:00
Owner

Fixes #76

Bodies indented inside the C annotation no longer leak that indentation into the proof document.

Fixes #76 Bodies indented inside the C annotation no longer leak that indentation into the proof document.
Dedent inline clause bodies before writing them (#76)
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 1m7s
Extension / Format, types, lint, extension tests (pull_request) Successful in 2m39s
5476289b13
michael requested changes 2026-10-29 10:54:06 +01:00
Dismissed
@ -14,0 +15,4 @@
/** Removes the indentation shared by every line. */
function dedent(body: string): string {
const lines = body.replace(/^[ \t]*\r?\n/, '').split(/\r?\n/);
while (lines.length > 0 && lines[lines.length - 1]?.trim() === '') {
Owner

why are empty lines being filtered away 3 times in this one method?

on this line, line 22 and line 37

why are empty lines being filtered away 3 times in this one method? on this line, line 22 and line 37
marfavi marked this conversation as resolved
marfavi referenced this pull request from a commit 2026-10-29 14:04:07 +01:00
# Conflicts:
#	examples/sumarray/sumarray.c
Handle inline clause blank lines once
All checks were successful
Grammar / Corpus and binding tests (pull_request) Successful in 45s
Extension / Format, types, lint, extension tests (pull_request) Successful in 1m54s
6e6dba0126
Drop surrounding blank lines with trimming and ignore interior blank lines only when measuring the common indentation, instead of filtering empty lines three times.

Stop trimming the dedented body as well: that removed indentation which was intentionally deeper than the common prefix.

Addresses review feedback on #84.
marfavi scheduled this pull request to auto merge when all checks succeed 2026-10-29 14:07:01 +01:00
michael approved these changes 2026-10-29 14:15:14 +01:00
marfavi deleted branch fix/inline-clause-whitespace 2026-10-29 14:15:18 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
code2rocq/crocq!84
No description provided.