Handle the case where text client fails to handle char attr request.

This commit is contained in:
Lukhnos D. Liu 2012-04-07 01:14:55 -07:00
parent e4c54e6bb9
commit c676d0d62c
1 changed files with 8 additions and 2 deletions

View File

@ -1034,14 +1034,20 @@ public:
[self updateClientComposingBuffer:client]; [self updateClientComposingBuffer:client];
_currentCandidateClient = client; _currentCandidateClient = client;
NSRect lineHeightRect; NSRect lineHeightRect = NSMakeRect(0.0, 0.0, 16.0, 16.0);
NSInteger cursor = _latestReadingCursor; NSInteger cursor = _latestReadingCursor;
if (cursor == [_composingBuffer length] && cursor != 0) { if (cursor == [_composingBuffer length] && cursor != 0) {
cursor--; cursor--;
} }
[client attributesForCharacterIndex:cursor lineHeightRectangle:&lineHeightRect]; // some apps (e.g. Twitter for Mac's search bar) handle this call incorrectly, hence the try-catch
@try {
[client attributesForCharacterIndex:cursor lineHeightRectangle:&lineHeightRect];
}
@catch (NSException *exception) {
NSLog(@"%@", exception);
}
[LTCurrentCandidateController setWindowTopLeftPoint:NSMakePoint(lineHeightRect.origin.x, lineHeightRect.origin.y - 4.0) bottomOutOfScreenAdjustmentHeight:lineHeightRect.size.height + 4.0]; [LTCurrentCandidateController setWindowTopLeftPoint:NSMakePoint(lineHeightRect.origin.x, lineHeightRect.origin.y - 4.0) bottomOutOfScreenAdjustmentHeight:lineHeightRect.size.height + 4.0];
LTCurrentCandidateController.visible = YES; LTCurrentCandidateController.visible = YES;