feat(prose): list shortcuts — S5 (#115)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
Markdown lists in the prose editor become structural: Tab/⇧Tab indent/outdent the item under the caret (wrapped lines ride along, caret follows), ⌥↑/⌥↓ move the item with its subtree among siblings. Every structural edit is one range replacement — a single undo step over the plain mode-B store (ADR-0010 stands). List parents fold visually: a gutter chevron collapses children to near-zero height with a rust ▸ and a "⋯ N" summary after the parent's line. Folding is view state — the buffer never changes (ADR-0013's posture carried to prose). Field findings baked in: SwiftUI-hosted TextKit2 never calls NSTextView.draw(_:) and every NSTextLayoutManager fragment query returns empty, so the chrome renders offscreen into a layer-contents image and geometry comes from firstRect(forCharacterRange:) (screen → window → view). Includes the finish-audit round: sibling block-for- block ⌥-move swap (was stealing the sibling's subtree), blank-line indent dirt, fold-key dedupe, hidden-parent chevron filtering, plain-click-only hit zone, no-parents raster skip. Closes #115 [Generated by AI]
This commit is contained in:
1 parent
c0513aae85
commit
c5c8749df4
12 files changed
+1142
-6
No files matched your search
@@ -347,7 +347,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
}
|
||||
|
||||
func makeNSView(context: Context) -> NSScrollView {
|
||||
let tv = NSTextView()
|
||||
let tv = ProseListTextView() // #115: list shortcuts + folds on the plain surface
|
||||
tv.isRichText = false // plain source of truth; attributes are presentation
|
||||
tv.allowsUndo = true
|
||||
tv.isAutomaticQuoteSubstitutionEnabled = false
|
||||
@@ -391,7 +391,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
}
|
||||
|
||||
func updateNSView(_ scroll: NSScrollView, context: Context) {
|
||||
guard let tv = scroll.documentView as? NSTextView else { return }
|
||||
guard let tv = scroll.documentView as? ProseListTextView else { return }
|
||||
// #77: posture toggle while editing — cheap idempotent set.
|
||||
tv.isContinuousSpellCheckingEnabled = spellChecking
|
||||
// #21: the ground follows focus in/out without a remount.
|
||||
@@ -414,6 +414,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// have flushed it over the user's real content (#71 fix).
|
||||
tv.textStorage?.setAttributedString(ProsePresenter.attribute(session.text))
|
||||
context.coordinator.fenceDelims = ProsePresenter.fenceDelimCount(session.text)
|
||||
tv.refreshFolds() // #115: re-key folds over the swapped content
|
||||
// #66: restore cursor (clamped) + scroll.
|
||||
let length = (tv.string as NSString).length
|
||||
var cursor = session.restoreCursor ?? PostStore.CursorState()
|
||||
@@ -433,6 +434,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// Echo guard: our own keystroke round-trips through the model —
|
||||
// only reload when the textview genuinely diverges (new draft).
|
||||
tv.textStorage?.setAttributedString(ProsePresenter.attribute(draft))
|
||||
tv.refreshFolds() // #115: re-key folds over the swapped content
|
||||
}
|
||||
// #71: flip-back caret — apply once per token, after any load above.
|
||||
if let hint = caretHint, context.coordinator.appliedCaretToken != hint.token {
|
||||
@@ -499,6 +501,8 @@ struct ProseTextView: NSViewRepresentable {
|
||||
} else {
|
||||
onEdit?(storage.string)
|
||||
}
|
||||
// #115: fold maintenance LAST — hidden styling over the refreshed presentation.
|
||||
(tv as? ProseListTextView)?.refreshFolds()
|
||||
}
|
||||
|
||||
func textViewDidChangeSelection(_ notification: Notification) {
|
||||
|
||||
Reference in new issue
Block a user