uttrflow / uttrflow/uttrflow-swift
Re-indent breaks valid Makefile recipes when a comment separates them from the rule
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## Problem
`CodeReindent.looksLikeMakefile` checks only the line immediately before a tab-indented line. A comment between the rule header and recipe prevents recognition. The normalizer then treats the recipe tab as presentation whitespace and can replace it with spaces, making a valid Makefile fail to parse.
## Verified reproduction
Against unmodified main `8d93f5b8574f3c7b8c30086d9c817bf7f5d4827d`, pass this string to the production `CodeReindent.reindented`:
```swift
"all:\n# Build target\n\t@echo ok\n X = 1\n"
```
The original has a tab before `@echo` and two spaces before the variable assignment. The result replaces the recipe tab with two spaces. A regression asserting refusal (`nil`) fails.
The production classifier returns `.code` for this input. `PanelPresenter` offers Re-indent for a code clip when this function returns a change, and `PanelChange.reindenting` forwards the changed text as `.rewriteText`.
A real `/usr/bin/make -n -f all` check gives:
- Original: exit **0**, stdout `echo ok`.
- Reindented output: exit **2**, `missing separator` at line 3.
This was a dry run: no recipe was executed. The test uses the actual Swift normalizer and classifier and real Makefile parsing; no UI click is claimed.
## Relevant code
- `Sources/UttrflowClipboard/CodeReindent.swift`: `looksLikeMakefile`, indentation inference, and reconstruction.
- `Sources/UttrflowUX/PanelPresentation.swift`: Re-indent eligibility.
- `Sources/UttrflowUX/PanelChange.swift`: `reindenting`.
- `Tests/UttrflowClipboardTests/CodeReindentTests.swift`: Makefile fixtures only put the recipe directly after its header. The leading-whitespace invariant cannot detect this syntax change, because leading whitespace is grammar here.
## Acceptance criteria
- Refuse normalization when comments or blank lines intervene between a Makefile rule and its recipe.
- Add regression cases for intervening comments and blank lines, including CRLF, while preserving existing safe transformations.
- Verify accepted transformations cannot convert a recipe tab into spaces in these cases.
Priority: P2 — a clipboard editing action turns valid code into invalid code. Distinct from #574, which concerns the cost of computing action eligibility.
Contributor guide
Research direction
Start in Sources/UttrflowClipboard/CodeReindent.swift, focusing on looksLikeMakefile, indentation inference, and reconstruction. Add regression coverage in Tests/UttrflowClipboardTests/CodeReindentTests.swift for comments and blank lines, including CRLF, then run the relevant tests and the real Makefile reproduction. Done means unsafe normalization is refused while existing safe transformations still pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 84/100