Skip to content

Commit b4fa0e3

Browse files
committed
1 parent a0042a6 commit b4fa0e3

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

FSNotes/View/EditTextView.swift

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ class EditTextView: NSTextView, NSTextFinderClient {
3737
}
3838

3939
override func becomeFirstResponder() -> Bool {
40-
if let note = EditTextView.note, note.container == .encryptedTextPack {
41-
return false
40+
if let note = EditTextView.note {
41+
if note.container == .encryptedTextPack {
42+
return false
43+
}
44+
45+
removeHighlight()
4246
}
4347

4448
return super.becomeFirstResponder()
@@ -1467,7 +1471,12 @@ class EditTextView: NSTextView, NSTextFinderClient {
14671471

14681472
public func scrollToCursor() {
14691473
let cursorRange = NSMakeRange(self.selectedRange().location, 0)
1470-
scrollRangeToVisible(cursorRange)
1474+
1475+
// DispatchQueue fixes rare bug when textStorage invalidation not working (blank page instead text)
1476+
1477+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
1478+
self.scrollRangeToVisible(cursorRange)
1479+
}
14711480
}
14721481

14731482
public func hasFocus() -> Bool {

0 commit comments

Comments
 (0)