diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-10-03 19:04:03 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-03 19:04:03 +0200 |
commit | aa38a667d1390235c8cc651adb546c01129619d0 (patch) | |
tree | 27f7b15c5f5b6eaf35a879af066e6b71e421a5f9 | |
parent | fe3e4759147e01a5542c2f3cbc1cf19884d6141f (diff) | |
parent | ee4a1c99a78a4fc2d39e953b358a764ef8eae0e4 (diff) |
Merge pull request #42534 from Paulb23/color_region_crash_issue_42492
Switch from recursion to iterative for backfilling colour regions
-rw-r--r-- | modules/gdscript/editor/gdscript_highlighter.cpp | 7 | ||||
-rw-r--r-- | scene/resources/syntax_highlighter.cpp | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/modules/gdscript/editor/gdscript_highlighter.cpp b/modules/gdscript/editor/gdscript_highlighter.cpp index 9a3273d201..7f7410a92c 100644 --- a/modules/gdscript/editor/gdscript_highlighter.cpp +++ b/modules/gdscript/editor/gdscript_highlighter.cpp @@ -73,6 +73,13 @@ Dictionary GDScriptSyntaxHighlighter::_get_line_syntax_highlighting(int p_line) color_region_cache[p_line] = -1; int in_region = -1; if (p_line != 0) { + int prev_region_line = p_line - 1; + while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) { + prev_region_line--; + } + for (int i = prev_region_line; i < p_line - 1; i++) { + get_line_syntax_highlighting(i); + } if (!color_region_cache.has(p_line - 1)) { get_line_syntax_highlighting(p_line - 1); } diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp index 5d58e71fc5..e7b49892d8 100644 --- a/scene/resources/syntax_highlighter.cpp +++ b/scene/resources/syntax_highlighter.cpp @@ -149,6 +149,13 @@ Dictionary CodeHighlighter::_get_line_syntax_highlighting(int p_line) { color_region_cache[p_line] = -1; int in_region = -1; if (p_line != 0) { + int prev_region_line = p_line - 1; + while (prev_region_line > 0 && !color_region_cache.has(prev_region_line)) { + prev_region_line--; + } + for (int i = prev_region_line; i < p_line - 1; i++) { + get_line_syntax_highlighting(i); + } if (!color_region_cache.has(p_line - 1)) { get_line_syntax_highlighting(p_line - 1); } |