uttrflow / uttrflow/uttrflow-swift
A one-line sentence that ends in a {placeholder} is classified as code, because one closing brace counts as two signals
- Dominant language
- Swift
- Stars
- 4
- Forks
- 17
- Avg merge
- 3h 32m
- Merged PRs (30d)
- 277
Description
## What happens
`CodeShapes.hasTwoSignals` (`Sources/UttrflowClipboard/CodeShapes.swift:20-58`) calls a clip code when two "independent" signals fire. Two of those signals are satisfied by the same character:
```swift
{ text.contains("{") && text.contains("}") }, // braces
{ hasStatementEnding(text) }, // a line that ends in ; or { or }
```
A line that ends in `}` fires both, so any one-line text that ends in a braced word is code.
## Measured (headless, `ClipKindDetector.kind(of:)`)
| Clip | Kind |
|---|---|
| `Hi {name}` | **code** |
| `Meeting notes {draft}` | **code** |
| `I said {sic}` | **code** |
| `To do: fix the bug {soon}` | **code** |
| `Dear {first_name},` | text |
| `Use the {name} placeholder in the template.` (already in the tests) | text |
The existing prose test only passes because its sentence ends in a full stop.
## Why it matters
Template placeholders, and editorial marks like `{sic}` and `{draft}`, are ordinary things to copy. They land under the Code tab, get a code tile and a monospaced font, and are offered Re-indent.
## Acceptance criteria
- A closing brace that ends a line does not count toward both signals. For example, `hasStatementEnding` counts `;` and a line ending in `{`, but a line ending in `}` only when the braces signal did not already fire. Or the two are merged into one signal.
- The four **code** rows above are `.text`. Everything in `ClipKindDetectorTests`, `ClipKindOracleTests` and `CodeLanguageTests` still passes, in particular one-line code such as `if (x > 0) { y = 1; }` and `func greet() {}`.
## Where to start
- `Sources/UttrflowClipboard/CodeShapes.swift:26-28` and `:60-66`
- Test to extend: `Tests/UttrflowClipboardTests/ClipKindDetectorTests.swift` (`prose`, around line 10)
- Before pushing, run `make verify` (export `DEVELOPER_DIR=/Applications/Xcode.app/Contents/Developer` first). It is the same command CI runs, and it enforces the 95% coverage floor per module.
- Read [CONTRIBUTING.md](https://github.com/uttrflow/uttrflow-swift/blob/main/CONTRIBUTING.md) first, and say on this issue that you are taking it.
**Size:** XS to S, about 1 hour.
Contributor guide
Assessment
This issue has not been assessed yet.