diff --git a/src/MacVim/MMCoreTextView.m b/src/MacVim/MMCoreTextView.m index 18a8fd927e..5fc385e7f5 100644 --- a/src/MacVim/MMCoreTextView.m +++ b/src/MacVim/MMCoreTextView.m @@ -1241,6 +1241,9 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances, { CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; NSRect rect = [self rectForRow:row column:col numRows:1 numColumns:1]; + CGRect clipRect = *(CGRect *)▭ + + CGContextSaveGState(context); if (MMInsertionPointHorizontal == shape) { int frac = (cellSize.height * percent + 99)/100; @@ -1259,6 +1262,12 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances, // over into adjacent display cells and it may look ugly. CGContextSetShouldAntialias(context, NO); + // Even though antialiasing is disabled and we adjust the rect to fit + // inside the display cell it still happens on Retina displays (only) that + // the cursor bleeds over into the neighboring cells. To work around this + // issue we enable clipping. + CGContextClipToRect(context, clipRect); + if (MMInsertionPointHollow == shape) { // When stroking a rect its size is effectively 1 pixel wider/higher // than we want so make it smaller to avoid having it bleed over into @@ -1275,7 +1284,7 @@ recurseDraw(const unichar *chars, CGGlyph *glyphs, CGSize *advances, CGContextFillRect(context, *(CGRect*)&rect); } - CGContextSetShouldAntialias(context, antialias); + CGContextRestoreGState(context); } - (void)drawInvertedRectAtRow:(int)row column:(int)col numRows:(int)nrows