diff options
-rw-r--r-- | source/blender/blenkernel/BKE_text.h | 1 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/text.c | 10 | ||||
-rw-r--r-- | source/blender/editors/space_text/text_autocomplete.c | 8 |
3 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/blenkernel/BKE_text.h b/source/blender/blenkernel/BKE_text.h index 1e3dd426efa..be30eba0559 100644 --- a/source/blender/blenkernel/BKE_text.h +++ b/source/blender/blenkernel/BKE_text.h @@ -105,6 +105,7 @@ int text_check_bracket(const char ch); int text_check_delim(const char ch); int text_check_digit(const char ch); int text_check_identifier(const char ch); +int text_check_identifier_nodigit(const char ch); int text_check_whitespace(const char ch); int text_find_identifier_start(const char *str, int i); diff --git a/source/blender/blenkernel/intern/text.c b/source/blender/blenkernel/intern/text.c index c337e339ebf..a0f611a5a7b 100644 --- a/source/blender/blenkernel/intern/text.c +++ b/source/blender/blenkernel/intern/text.c @@ -2930,6 +2930,16 @@ int text_check_identifier(const char ch) return 0; } +int text_check_identifier_nodigit(const char ch) +{ + if (ch <= '9') return 0; + if (ch < 'A') return 0; + if (ch <= 'Z' || ch == '_') return 1; + if (ch < 'a') return 0; + if (ch <= 'z') return 1; + return 0; +} + int text_check_whitespace(const char ch) { if (ch == ' ' || ch == '\t' || ch == '\r' || ch == '\n') diff --git a/source/blender/editors/space_text/text_autocomplete.c b/source/blender/editors/space_text/text_autocomplete.c index e406a1b7166..94977fc5f0f 100644 --- a/source/blender/editors/space_text/text_autocomplete.c +++ b/source/blender/editors/space_text/text_autocomplete.c @@ -167,7 +167,7 @@ static GHash *text_autocomplete_build(Text *text) while (i_start < linep->len) { /* seek identifier beginning */ - while (i_start < linep->len && !text_check_identifier(linep->line[i_start])) { + while (i_start < linep->len && !text_check_identifier_nodigit(linep->line[i_start])) { i_start++; } i_end = i_start; @@ -175,7 +175,11 @@ static GHash *text_autocomplete_build(Text *text) i_end++; } - if (i_start != i_end) { + 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]))) + { char *str_sub = &linep->line[i_start]; const int choice_len = i_end - i_start; |