fix(editor): source-editor spacing — blank lines are the separator (#71 follow-up 8)
Two defects from the flow-knob commit: (1) edit mode got reading-mode's paragraph spacing stacked on top of the visible blank source lines — gaps tripled. Source editors render the blank line AS the separator; paragraph spacing is now 0, only lineHeightMultiple rides the knobs. (2) Knob changes never reached an open editor — updateNSView now re-attributes the whole storage (selection preserved) when ProseTypography.flowKey moves.
This commit is contained in:
1 parent
6d7d1411a2
commit
677dc8c073
3 files changed
+22
-7
No files matched your search
@@ -297,6 +297,15 @@ struct ProseTextView: NSViewRepresentable {
|
||||
|
||||
func updateNSView(_ scroll: NSScrollView, context: Context) {
|
||||
guard let tv = scroll.documentView as? NSTextView else { return }
|
||||
// Typography/flow knob change: re-attribute everything, keep text
|
||||
// and selection (settings live in another pane; the editor is idle).
|
||||
if context.coordinator.appliedFlowKey != ProseTypography.flowKey {
|
||||
context.coordinator.appliedFlowKey = ProseTypography.flowKey
|
||||
let sel = tv.selectedRange()
|
||||
let storage = tv.textStorage as! NSMutableAttributedString
|
||||
storage.setAttributedString(ProsePresenter.attribute(tv.string))
|
||||
tv.setSelectedRange(sel)
|
||||
}
|
||||
if let session {
|
||||
context.coordinator.sessionRef = session
|
||||
// Load only when the generation moved (open, Yes-reload) — never
|
||||
@@ -348,6 +357,7 @@ struct ProseTextView: NSViewRepresentable {
|
||||
var sessionRef: EditorSession?
|
||||
var loadedGeneration = -1
|
||||
var appliedCaretToken = -1
|
||||
var appliedFlowKey = ""
|
||||
|
||||
init(representable: ProseTextView) {
|
||||
onEdit = representable.onEdit
|
||||
|
||||
Reference in new issue
Block a user