Skip to content
Snippets Groups Projects
Commit e870cdd3 authored by George Nachman's avatar George Nachman
Browse files

Work around bug in 10.9 where insertText: is called on the wrong view (bug 2743)

parent a223af45
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -91,6 +91,8 @@ static double gSmartCursorBgThreshold = 0.5;
// B/W text mode is triggered. 0 means always trigger, 1 means never trigger.
static double gSmartCursorFgThreshold = 0.75;
 
static PTYTextView *gCurrentKeyEventTextView; // See comment in -keyDown:
@implementation FindCursorView
 
@synthesize cursor;
Loading
Loading
@@ -2487,7 +2489,14 @@ NSMutableArray* screens=0;
if (debugKeyDown) {
NSLog(@"PTYTextView keyDown send to IME");
}
// In issue 2743, it is revealed that in OS 10.9 this sometimes calls -insertText on the
// wrong instnace of PTYTextView. We work around the issue by using a global variable to
// track the instance of PTYTextView that is currently handling a key event and rerouting
// calls as needed in -insertText and -doCommandBySelector.
gCurrentKeyEventTextView = [[self retain] autorelease];
[self interpretKeyEvents:[NSArray arrayWithObject:event]];
gCurrentKeyEventTextView = nil;
 
// If the IME didn't want it, pass it on to the delegate
if (!prev &&
Loading
Loading
@@ -4848,7 +4857,13 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
/// NSTextInput stuff
- (void)doCommandBySelector:(SEL)aSelector
{
//NSLog(@"doCommandBySelector:%@", NSStringFromSelector(aSelector));
if (gCurrentKeyEventTextView && self != gCurrentKeyEventTextView) {
// See comment in -keyDown:
DLog(@"Rerouting doCommandBySelector from %@ to %@", self, gCurrentKeyEventTextView);
[gCurrentKeyEventTextView doCommandBySelector:aSelector];
return;
}
DLog(@"doCommandBySelector:%@", NSStringFromSelector(aSelector));
 
#if GREED_KEYDOWN == 0
id delegate = [self delegate];
Loading
Loading
@@ -4861,6 +4876,13 @@ static double EuclideanDistance(NSPoint p1, NSPoint p2) {
 
- (void)insertText:(id)aString
{
if (gCurrentKeyEventTextView && self != gCurrentKeyEventTextView) {
// See comment in -keyDown:
DLog(@"Rerouting insertText from %@ to %@", self, gCurrentKeyEventTextView);
[gCurrentKeyEventTextView insertText:aString];
return;
}
DLog(@"PTYTextView insertText:%@", aString);
if ([self hasMarkedText]) {
BOOL debugKeyDown = [[[NSUserDefaults standardUserDefaults] objectForKey:@"DebugKeyDown"] boolValue];
if (debugKeyDown) {
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment