From 69df0a683aed2f3f5240894a8852514fc6458469 Mon Sep 17 00:00:00 2001 From: Neil Hodgson Date: Sat, 4 Mar 2017 10:30:52 +1100 Subject: Fix error with showing find indicator over styles > 127. --- cocoa/ScintillaCocoa.mm | 4 +++- cocoa/ScintillaView.mm | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/cocoa/ScintillaCocoa.mm b/cocoa/ScintillaCocoa.mm index 4a451649b..1400796be 100644 --- a/cocoa/ScintillaCocoa.mm +++ b/cocoa/ScintillaCocoa.mm @@ -2643,7 +2643,9 @@ void ScintillaCocoa::ShowFindIndicatorForRange(NSRange charRange, BOOL retaining CFRelease(cfsFind); layerFindIndicator.retaining = retaining; layerFindIndicator.positionFind = static_cast(charRange.location); - long style = WndProc(SCI_GETSTYLEAT, charRange.location, 0); + // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles + const char styleByte = static_cast(WndProc(SCI_GETSTYLEAT, charRange.location, 0)); + const long style = static_cast(styleByte); std::vector bufferFontName(WndProc(SCI_STYLEGETFONT, style, 0) + 1); WndProc(SCI_STYLEGETFONT, style, (sptr_t)&bufferFontName[0]); layerFindIndicator.sFont = [NSString stringWithUTF8String: &bufferFontName[0]]; diff --git a/cocoa/ScintillaView.mm b/cocoa/ScintillaView.mm index 61c471d6a..d4ad526d7 100644 --- a/cocoa/ScintillaView.mm +++ b/cocoa/ScintillaView.mm @@ -442,7 +442,9 @@ static NSCursor *cursorFromEnum(Window::Cursor cursor) NSMutableAttributedString *asResult = [[[NSMutableAttributedString alloc] initWithString:result] autorelease]; const NSRange rangeAS = NSMakeRange(0, [asResult length]); - const long style = [mOwner message: SCI_GETSTYLEAT wParam:posRange.location]; + // SCI_GETSTYLEAT reports a signed byte but want an unsigned to index into styles + const char styleByte = static_cast([mOwner message: SCI_GETSTYLEAT wParam:posRange.location]); + const long style = static_cast(styleByte); std::string fontName([mOwner message: SCI_STYLEGETFONT wParam:style lParam:0] + 1, 0); [mOwner message: SCI_STYLEGETFONT wParam:style lParam:(sptr_t)&fontName[0]]; const CGFloat fontSize = [mOwner message: SCI_STYLEGETSIZEFRACTIONAL wParam:style] / 100.0f; -- cgit v1.2.3