Fix crash in text editor (wrap + syntax-highlight)

This commit is contained in:
Campbell Barton 2014-09-24 01:10:59 +10:00
parent 8ddc3d148e
commit 55a44e4f30
1 changed files with 6 additions and 2 deletions

View File

@ -377,6 +377,7 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
FlattenString fs;
int basex, lines;
int i, wrap, end, max, columns, padding; /* column */
/* warning, only valid when 'use_syntax' is set */
int a, fstart, fpos; /* utf8 chars */
int mi, ma, mstart, mend; /* mem */
char fmt_prev = 0xff;
@ -398,8 +399,11 @@ static int text_draw_wrapped(SpaceText *st, const char *str, int x, int y, int w
/* skip hidden part of line */
if (skip) {
skip--;
fstart = fpos = end;
mstart = mend;
if (use_syntax) {
/* currently fpos only used when formatting */
fpos += BLI_strnlen_utf8(str + mstart, mend - mstart);
}
fstart = fpos; mstart = mend;
mend = txt_utf8_forward_columns(str + mend, max, &padding) - str;
end = (wrap += max - padding);
continue;