Skip to content
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 @@ -221,7 +221,6 @@ public class TextSelectionManager: NSObject {
.getLine(atOffset: range.location - (selectedLine.range.location))?
.height
?? layoutManager?.estimateLineHeight()

}

/// Removes all cursor views and stops the cursor blink timer.
Expand Down
4 changes: 3 additions & 1 deletion Sources/CodeEditTextView/TextView/TextView+Layout.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ extension TextView {
public func updateFrameIfNeeded() -> Bool {
var availableSize = scrollView?.contentSize ?? .zero
availableSize.height -= (scrollView?.contentInsets.top ?? 0) + (scrollView?.contentInsets.bottom ?? 0)
let newHeight = max(layoutManager.estimatedHeight(), availableSize.height)

let extraHeight = availableSize.height * overscrollAmount
let newHeight = max(layoutManager.estimatedHeight() + extraHeight, availableSize.height)
let newWidth = layoutManager.estimatedWidth()

var didUpdate = false
Expand Down
10 changes: 10 additions & 0 deletions Sources/CodeEditTextView/TextView/TextView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,16 @@ public class TextView: NSView, NSTextContent {
}
}

/// The amount of extra space to add when overscroll is enabled, as a percentage of the viewport height
public var overscrollAmount: CGFloat = 0.5 {
didSet {
if overscrollAmount < 0 {
overscrollAmount = 0
}
updateFrameIfNeeded()
}
}

/// Whether or not the editor should wrap lines
public var wrapLines: Bool {
get {
Expand Down