Fix scroll lock after large paste in editor

This commit is contained in:
h3p 2026-02-08 17:47:47 +01:00
parent 9e70954059
commit d59a90aeeb
2 changed files with 13 additions and 0 deletions

View file

@ -263,6 +263,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
AUTOMATION_APPLE_EVENTS = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 105;
DEAD_CODE_STRIPPING = YES;
@ -335,6 +336,7 @@
ASSETCATALOG_COMPILER_INCLUDE_ALL_APPICON_ASSETS = NO;
AUTOMATION_APPLE_EVENTS = NO;
CODE_SIGN_IDENTITY = "Apple Development";
"CODE_SIGN_IDENTITY[sdk=macosx*]" = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 105;
DEAD_CODE_STRIPPING = YES;

View file

@ -39,10 +39,16 @@ final class AcceptingTextView: NSTextView {
}
override func mouseDown(with event: NSEvent) {
cancelPendingPasteCaretEnforcement()
super.mouseDown(with: event)
window?.makeFirstResponder(self)
}
override func scrollWheel(with event: NSEvent) {
cancelPendingPasteCaretEnforcement()
super.scrollWheel(with: event)
}
override func becomeFirstResponder() -> Bool {
let didBecome = super.becomeFirstResponder()
if didBecome, UserDefaults.standard.bool(forKey: vimModeDefaultsKey) {
@ -517,6 +523,11 @@ final class AcceptingTextView: NSTextView {
}
}
private func cancelPendingPasteCaretEnforcement() {
pendingPasteCaretLocation = nil
NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(applyPendingPasteCaret), object: nil)
}
@objc private func applyPendingPasteCaret() {
guard let desired = pendingPasteCaretLocation else { return }