diff options
Diffstat (limited to 'source/blender/editors/space_text/text_format_py.c')
-rw-r--r-- | source/blender/editors/space_text/text_format_py.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c index cbccc6a770f..902d60dcb3e 100644 --- a/source/blender/editors/space_text/text_format_py.c +++ b/source/blender/editors/space_text/text_format_py.c @@ -231,9 +231,9 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const int do_ne /* Not in a string... */ else { /* Deal with comments first */ - if (prev == FMT_TYPE_COMMENT || *str == '#') { - *fmt = FMT_TYPE_COMMENT; - str += BLI_str_utf8_size_safe(str) - 1; + if (*str == '#') { + /* fill the remaining line */ + text_format_fill(&str, &fmt, FMT_TYPE_COMMENT, len - (int)(str - fs.buf)); } else if (*str == '"' || *str == '\'') { /* Strings */ @@ -259,8 +259,7 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const int do_ne /* Booleans */ else if (prev != FMT_TYPE_DEFAULT && (i = txtfmt_py_find_bool(str)) != -1) { if (i > 0) { - memset(fmt, FMT_TYPE_NUMERAL, i); - i--; fmt += i; str += i; + text_format_fill_ascii(&str, &fmt, FMT_TYPE_NUMERAL, i); } else { str += BLI_str_utf8_size_safe(str) - 1; @@ -285,8 +284,12 @@ static void txtfmt_py_format_line(SpaceText *st, TextLine *line, const int do_ne else if ((i = txtfmt_py_find_decorator(str)) != -1) prev = FMT_TYPE_DIRECTIVE; if (i > 0) { - memset(fmt, prev, i); - i--; fmt += i; str += i; + if (prev == FMT_TYPE_DIRECTIVE) { /* can contain utf8 */ + text_format_fill(&str, &fmt, prev, i); + } + else { + text_format_fill_ascii(&str, &fmt, prev, i); + } } else { str += BLI_str_utf8_size_safe(str) - 1; |