summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-10-22 20:40:20 +0200
committerGitHub <noreply@github.com>2019-10-22 20:40:20 +0200
commit9f28803927330654cdb09f48467b481c85209ea8 (patch)
tree769980b79ee5ca985346ae74997c076d233076eb
parentb365dc344149eb6156342f12c4a2d00cca5727e3 (diff)
parent4247c21cb0ab579a0ba490b858daa3404967f5ce (diff)
Merge pull request #32940 from nekomatata/text-edit-clear-colors
TextEdit syntax highlighting fixes
-rw-r--r--doc/classes/TextEdit.xml2
-rw-r--r--scene/gui/text_edit.cpp6
2 files changed, 7 insertions, 1 deletions
diff --git a/doc/classes/TextEdit.xml b/doc/classes/TextEdit.xml
index 8a114efd34..27eab85301 100644
--- a/doc/classes/TextEdit.xml
+++ b/doc/classes/TextEdit.xml
@@ -54,7 +54,7 @@
<return type="void">
</return>
<description>
- Clears all the syntax coloring information.
+ Clears all custom syntax coloring information previously added with [method add_color_region] or [method add_keyword_color].
</description>
</method>
<method name="clear_undo_history">
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index e35d858635..42afde9a0c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -5063,15 +5063,18 @@ Map<int, TextEdit::Text::ColorRegionInfo> TextEdit::_get_line_color_region_info(
void TextEdit::clear_colors() {
keywords.clear();
+ member_keywords.clear();
color_regions.clear();
color_region_cache.clear();
syntax_highlighting_cache.clear();
text.clear_width_cache();
+ update();
}
void TextEdit::add_keyword_color(const String &p_keyword, const Color &p_color) {
keywords[p_keyword] = p_color;
+ syntax_highlighting_cache.clear();
update();
}
@@ -5088,12 +5091,14 @@ Color TextEdit::get_keyword_color(String p_keyword) const {
void TextEdit::add_color_region(const String &p_begin_key, const String &p_end_key, const Color &p_color, bool p_line_only) {
color_regions.push_back(ColorRegion(p_begin_key, p_end_key, p_color, p_line_only));
+ syntax_highlighting_cache.clear();
text.clear_width_cache();
update();
}
void TextEdit::add_member_keyword(const String &p_keyword, const Color &p_color) {
member_keywords[p_keyword] = p_color;
+ syntax_highlighting_cache.clear();
update();
}
@@ -5107,6 +5112,7 @@ Color TextEdit::get_member_color(String p_member) const {
void TextEdit::clear_member_keywords() {
member_keywords.clear();
+ syntax_highlighting_cache.clear();
update();
}