Skip to content

Commit ed43078

Browse files
committed
Add Find Panel Height when Setting Up Scroll View
1 parent 56acf85 commit ed43078

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

Sources/CodeEditSourceEditor/Controller/TextViewController+LoadView.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ extension TextViewController {
3636
findViewController.view.viewDidMoveToSuperview()
3737
self.findViewController = findViewController
3838

39-
findViewController.topPadding = contentInsets?.top ?? view.safeAreaInsets.top
39+
findViewController.topPadding = contentInsets?.top
4040

4141
if let _undoManager {
4242
textView.setUndoManager(_undoManager)

Sources/CodeEditSourceEditor/Controller/TextViewController+StyleViews.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,6 @@ extension TextViewController {
7474
} else {
7575
scrollView.automaticallyAdjustsContentInsets = true
7676
}
77-
scrollView.contentInsets.bottom = contentInsets?.bottom ?? 0
77+
scrollView.contentInsets.top += (findViewController?.isShowingFindPanel ?? false) ? FindPanel.height : 0
7878
}
7979
}

Sources/CodeEditSourceEditor/Controller/TextViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public class TextViewController: NSViewController {
130130
/// Optional insets to offset the text view in the scroll view by.
131131
public var contentInsets: NSEdgeInsets? {
132132
didSet {
133-
findViewController?.topPadding = contentInsets?.top ?? view.safeAreaInsets.top
133+
findViewController?.topPadding = contentInsets?.top
134134
}
135135
}
136136

Sources/CodeEditSourceEditor/Find/FindViewController+Operations.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,11 @@ import CodeEditTextView
1111
extension FindViewController {
1212
func find(text: String) {
1313
findText = text
14-
performFind(query: text)
14+
performFind()
1515
addEmphases()
1616
}
1717

18-
func performFind(query: String) {
18+
func performFind() {
1919
// Don't find if target or emphasisManager isn't ready
2020
guard let target = target else {
2121
findPanel.findDelegate?.findPanelUpdateMatchCount(0)
@@ -25,15 +25,15 @@ extension FindViewController {
2525
}
2626

2727
// Clear emphases and return if query is empty
28-
if query.isEmpty {
28+
if findText.isEmpty {
2929
findPanel.findDelegate?.findPanelUpdateMatchCount(0)
3030
findMatches = []
3131
currentFindMatchIndex = 0
3232
return
3333
}
3434

35-
let findOptions: NSRegularExpression.Options = smartCase(str: query) ? [] : [.caseInsensitive]
36-
let escapedQuery = NSRegularExpression.escapedPattern(for: query)
35+
let findOptions: NSRegularExpression.Options = smartCase(str: findText) ? [] : [.caseInsensitive]
36+
let escapedQuery = NSRegularExpression.escapedPattern(for: findText)
3737

3838
guard let regex = try? NSRegularExpression(pattern: escapedQuery, options: findOptions) else {
3939
findPanel.findDelegate?.findPanelUpdateMatchCount(0)

0 commit comments

Comments
 (0)