fix(editor): reading-mode layout + stale-reload defects (#71 follow-up)
Five root causes behind Alexander's calibration findings: - Wrap to column: both canvases had a fixed 640pt text container — clipped instead of wrapping when the editor column is narrower (library + mentor open). widthTracksTextView = true now; measure polish can return with calibration. - Tables: TextKit2 stacks NSTextTable rows vertically (each row its own content-width fragment — no grid). The reading canvas forces the TextKit1 bridge (replaceLayoutManager); probe-verified grid + column borders. Read-only canvas — nothing editing-grade lost. - Heading-tail: a chunk like "# Title" followed by body lines (single newline, legal markdown) dropped everything after line one. The heading now renders, then the remaining lines as a soft-joined paragraph. - Stale reload (data-loss vector): ProseTextView seeded from session.loadText (open-time snapshot) — after a reading⇄editing swap the recreated editor showed the pre-paste text, and a keystroke there flushed stale content over the user's real edits. Seeds from session.text (live) now. - Quote one-char-per-line: did not reproduce after the layout fixes; root cause was the broken layout state above. EditorSessionTests debounce flake (50ms margin under parallel load) passed on both re-runs — timing margin, not a regression. Full suite green (94 unit + UI smoke); lint clean.
This commit is contained in:
1 parent
36858bcf1d
commit
c410c99bf8
4 files changed
+34
-9
No files matched your search
@@ -278,8 +278,10 @@ struct ProseTextView: NSViewRepresentable {
|
||||
tv.isVerticallyResizable = true
|
||||
tv.isHorizontallyResizable = false
|
||||
tv.autoresizingMask = [.width]
|
||||
tv.textContainer?.containerSize = NSSize(width: 640, height: CGFloat.greatestFiniteMagnitude)
|
||||
tv.textContainer?.widthTracksTextView = false
|
||||
// Wrap to the editor column (#71 fix): the container tracks the view
|
||||
// width — the fixed 640pt measure clipped in narrower columns.
|
||||
tv.textContainer?.containerSize = NSSize(width: 0, height: CGFloat.greatestFiniteMagnitude)
|
||||
tv.textContainer?.widthTracksTextView = true
|
||||
tv.textContainer?.lineFragmentPadding = 12
|
||||
tv.textContainerInset = NSSize(width: 0, height: 20)
|
||||
let scroll = NSScrollView()
|
||||
@@ -301,7 +303,12 @@ struct ProseTextView: NSViewRepresentable {
|
||||
// per keystroke: the text view owns the live text.
|
||||
if context.coordinator.loadedGeneration != session.loadGeneration {
|
||||
context.coordinator.loadedGeneration = session.loadGeneration
|
||||
tv.textStorage?.setAttributedString(ProsePresenter.attribute(session.loadText))
|
||||
// Seed from session.text (LIVE), not session.loadText (the
|
||||
// open-time snapshot): the representable is recreated on the
|
||||
// reading⇄editing swap, and seeding from the snapshot showed
|
||||
// pre-edit text — then session.edit on the stale view would
|
||||
// have flushed it over the user's real content (#71 fix).
|
||||
tv.textStorage?.setAttributedString(ProsePresenter.attribute(session.text))
|
||||
// #66: restore cursor (clamped) + scroll.
|
||||
let length = (tv.string as NSString).length
|
||||
var cursor = session.restoreCursor ?? PostStore.CursorState()
|
||||
|
||||
Reference in new issue
Block a user