v1.4.2 release: live-coding editor — Run Selection, slot release, engine panel, console, manual completion

Additive conveniences to the macOS-only Live Scratch editor. No changes to
existing public API.

- Run Selection (⌘E): evaluate just the highlighted text, additively.
- Graceful slot release: context.release(slot:) / free(slot:).
- Engine panel: live oscilloscope (ScopeCapture) + CPU avg/peak + counts.
- Reset Session / Restart to Reclaim Memory.
- Always-open console panel (report messages + errors with line:col).
- Faster typing: debounced highlight, updateNSView fast-path, publish guards.
- Manual code completion (Esc / F5), no auto-trigger on `.`; completion
  replaces the partial word, not the receiver expression.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
2026-07-21 11:09:30 -07:00
parent abc64df4d7
commit 8519cabe42
21 changed files with 1578 additions and 145 deletions
@@ -38,14 +38,49 @@ struct ScratchTextViewTests {
#expect(range == NSRange(location: text.utf16.count, length: 0))
}
/// Mid-identifier (no preceding dot) falls through to the default behavior,
/// which covers the whole partial word so it gets replaced on completion.
@Test func partialIdentifierUsesDefaultWordRange() {
/// Mid-identifier (no preceding dot): the range covers the run of identifier
/// characters before the caret, so the partial word gets replaced.
@Test func partialIdentifierCoversWordRange() {
let tv: ScratchTextView = makeTextView("OscSi", caret: 5)
let range: NSRange = tv.rangeForUserCompletion
// Default range spans the partial word `OscSi` (length 5 from offset 0).
#expect(range == NSRange(location: 0, length: 5))
}
/// Right after an open paren, the range is EMPTY at the caret — an argument
/// label (`freq:`) inserts there instead of replacing the receiver
/// (`OscSin.Audio(` → erases `OscSin.Audio` bug).
@Test func afterOpenParenRangeIsEmptyAtCaret() {
let text: String = "OscSin.Audio("
let tv: ScratchTextView = makeTextView(text, caret: text.utf16.count)
let range: NSRange = tv.rangeForUserCompletion
#expect(range == NSRange(location: text.utf16.count, length: 0))
}
/// After a comma + space (next argument position), the range is empty too.
@Test func afterCommaSpaceRangeIsEmptyAtCaret() {
let text: String = "OscSin.Audio(freq: 440, "
let tv: ScratchTextView = makeTextView(text, caret: text.utf16.count)
let range: NSRange = tv.rangeForUserCompletion
#expect(range == NSRange(location: text.utf16.count, length: 0))
}
/// A partial argument label inside parens replaces just that partial word,
/// not the receiver expression.
@Test func partialArgLabelCoversOnlyThePartial() {
let text: String = "OscSin.Audio(fr"
let tv: ScratchTextView = makeTextView(text, caret: text.utf16.count)
let range: NSRange = tv.rangeForUserCompletion
// `fr` starts at offset 13 (after `OscSin.Audio(`), length 2.
#expect(range == NSRange(location: 13, length: 2))
}
/// Underscore is an identifier character, so a leading-underscore partial is
/// covered whole.
@Test func underscoreIsIdentifierChar() {
let tv: ScratchTextView = makeTextView("_foo", caret: 4)
let range: NSRange = tv.rangeForUserCompletion
#expect(range == NSRange(location: 0, length: 4))
}
}
#endif