Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Padding Issue, Assertion Failure On Width Update #53

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading