Change !BLI_ghashIterator_isDone to BLI_ghashIterator_notDone. It is
[blender.git] / source / blender / editors / space_text / text_autocomplete.c
index 94977fc5f0f6a452fabfe5c8e7e6078a474d0563..106093d2531999f0aa38d2b96f134f6470152c0a 100644 (file)
@@ -162,23 +162,29 @@ static GHash *text_autocomplete_build(Text *text)
                gh = BLI_ghash_str_new(__func__);
 
                for (linep = text->lines.first; linep; linep = linep->next) {
-                       int i_start = 0;
-                       int i_end = 0;
+                       size_t i_start = 0;
+                       size_t i_end = 0;
+                       size_t i_pos = 0;
 
                        while (i_start < linep->len) {
                                /* seek identifier beginning */
-                               while (i_start < linep->len && !text_check_identifier_nodigit(linep->line[i_start])) {
-                                       i_start++;
+                               i_pos = i_start;
+                               while ((i_start < linep->len) &&
+                                      (!text_check_identifier_nodigit_unicode(BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_start], &i_pos))))
+                               {
+                                       i_start = i_pos;
                                }
-                               i_end = i_start;
-                               while (i_end < linep->len && text_check_identifier(linep->line[i_end])) {
-                                       i_end++;
+                               i_pos = i_end = i_start;
+                               while ((i_end < linep->len) &&
+                                      (text_check_identifier_unicode(BLI_str_utf8_as_unicode_and_size_safe(&linep->line[i_end], &i_pos))))
+                               {
+                                       i_end = i_pos;
                                }
 
                                if ((i_start != i_end) &&
                                    /* check we're at the beginning of a line or that the previous char is not an identifier
-                                        * this prevents digits from being added */
-                                   ((i_start < 1) || !text_check_identifier(linep->line[i_start - 1])))
+                                    * this prevents digits from being added */
+                                   ((i_start < 1) || !text_check_identifier_unicode(BLI_str_utf8_as_unicode(&linep->line[i_start - 1]))))
                                {
                                        char *str_sub = &linep->line[i_start];
                                        const int choice_len = i_end - i_start;
@@ -197,7 +203,13 @@ static GHash *text_autocomplete_build(Text *text)
                                                str_sub[choice_len] = str_sub_last;
                                        }
                                }
-                               i_start = i_end;
+                               if (i_end != i_start) {
+                                       i_start = i_end;
+                               }
+                               else {
+                                       /* highly unlikely, but prevent eternal loop */
+                                       i_start++;
+                               }
                        }
                }
 
@@ -208,7 +220,7 @@ static GHash *text_autocomplete_build(Text *text)
                        TextFormatType *tft;
                        tft = ED_text_format_get(text);
 
-                       for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) {
+                       for (; BLI_ghashIterator_notDone(iter); BLI_ghashIterator_step(iter)) {
                                const char *s = BLI_ghashIterator_getValue(iter);
                                texttool_suggest_add(s, tft->format_identifier(s));
                        }