Skip to content

Commit

Permalink
Fix Padding Issue, Assertion Failure On Width Update (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
thecoolwinter authored Nov 8, 2024
1 parent e5369da commit 3ddd279
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ extension TextLayoutManager {
}

public func estimatedWidth() -> CGFloat {
maxLineWidth
maxLineWidth + edgeInsets.horizontal
}

/// Finds a text line for the given y position relative to the text view.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,6 @@ public class TextLayoutManager: NSObject {
// Update the visible lines with the new set.
visibleLineIds = newVisibleLines

if originalHeight != lineStorage.height || layoutView?.frame.size.height != lineStorage.height {
delegate?.layoutManagerHeightDidUpdate(newHeight: lineStorage.height)
}

if maxFoundLineWidth > maxLineWidth {
maxLineWidth = maxFoundLineWidth
}
Expand All @@ -282,6 +278,11 @@ public class TextLayoutManager: NSObject {
isInLayout = false
#endif
needsLayout = false

// This needs to happen after ``needsLayout`` is toggled. Things can be triggered by frame changes.
if originalHeight != lineStorage.height || layoutView?.frame.size.height != lineStorage.height {
delegate?.layoutManagerHeightDidUpdate(newHeight: lineStorage.height)
}
}

/// Lays out a single text line.
Expand Down
2 changes: 1 addition & 1 deletion Sources/CodeEditTextView/TextView/TextView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ extension TextView {
if didUpdate {
needsLayout = true
needsDisplay = true
layoutManager.layoutLines()
layoutManager.setNeedsLayout()
}

if isSelectable {
Expand Down

0 comments on commit 3ddd279

Please sign in to comment.