From 9c517cb4e993d53628ed84dd7c4e3d4d8497be3d Mon Sep 17 00:00:00 2001 From: Bjorn Winckler Date: Fri, 6 Jun 2008 14:24:49 +0200 Subject: [PATCH] Don't draw control chars in MMTextStorage It can happen that MMTextStorage is asked to draw characters from the "Control Characters" set (e.g. when :shell is invoked). This would cause internal errors in MMTextStorage so when control chars are detected, simply draw blanks instead. --- src/MacVim/MMTextStorage.m | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/MacVim/MMTextStorage.m b/src/MacVim/MMTextStorage.m index 284cefcad8..2d6fd7751f 100644 --- a/src/MacVim/MMTextStorage.m +++ b/src/MacVim/MMTextStorage.m @@ -258,6 +258,16 @@ static NSString *MMWideCharacterAttributeName = @"MMWideChar"; || col+cells > maxColumns || !string || !(fg && bg && sp)) return; + BOOL hasControlChars = [string rangeOfCharacterFromSet: + [NSCharacterSet controlCharacterSet]].location != NSNotFound; + if (hasControlChars) { + // HACK! If a string for some reason contains control characters, then + // draw blanks instead (otherwise charRangeForRow::: fails). + NSRange subRange = { 0, cells }; + flags &= ~DRAW_WIDE; + string = [[emptyRowString string] substringWithRange:subRange]; + } + // Find range of characters in text storage to replace. int acol = col; int acells = cells;