Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacques Lucke <mail@jlucke.com>2019-03-11 18:14:46 +0300
committerJacques Lucke <mail@jlucke.com>2019-03-11 18:15:46 +0300
commit81d5f15a2a71eaa7c506b0b87706059b9c48d23a (patch)
tree676c0b14b22343c7db62e98e41f1489b893137af /source/blender/editors/space_text
parenta65b068f6eb31b7ca251075a8362b2098fecafd4 (diff)
Fix T61253: Wrong syntax highlighting when @ is used as multiplication
This is obviously not a perfect solution. However, to do proper highlighting a more advanced Python parser would be necessary. I think this patch implements a good heuristic to differentiate between the cases when `@` is used for a decorator vs for multiplication. When `@` is directly followed by an identifier, it is interpreted as decorated. Otherwise not. Reviewers: brecht Differential Revision: https://developer.blender.org/D4495
Diffstat (limited to 'source/blender/editors/space_text')
-rw-r--r--source/blender/editors/space_text/text_format_py.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/source/blender/editors/space_text/text_format_py.c b/source/blender/editors/space_text/text_format_py.c
index d7dc9d625f5..85c3c4220c0 100644
--- a/source/blender/editors/space_text/text_format_py.c
+++ b/source/blender/editors/space_text/text_format_py.c
@@ -116,18 +116,22 @@ static int txtfmt_py_find_specialvar(const char *string)
static int txtfmt_py_find_decorator(const char *string)
{
- if (string[0] == '@') {
- int i = 1;
- /* Whitespace is ok '@ foo' */
- while (text_check_whitespace(string[i])) {
- i++;
- }
- while (text_check_identifier(string[i])) {
- i++;
- }
- return i;
+ if (string[0] != '@') {
+ return -1;
+ }
+ if (!text_check_identifier(string[1])) {
+ return -1;
}
- return -1;
+ /* Interpret as matrix multiplication when followed by whitespace. */
+ if (text_check_whitespace(string[1])) {
+ return -1;
+ }
+
+ int i = 1;
+ while (text_check_identifier(string[i])) {
+ i++;
+ }
+ return i;
}
static int txtfmt_py_find_bool(const char *string)