summaryrefslogtreecommitdiffstats
path: root/scene
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2024-05-28 15:49:19 +0200
committerRémi Verschelde <rverschelde@gmail.com>2024-05-28 15:49:19 +0200
commit194b1c478d3868bf0cfb4edff93535ca484e643b (patch)
tree0f5882887f036213e71c515dc0cb244151e87a97 /scene
parent981ac9bfeb1ad887294c84430246e451f1a79aac (diff)
parent05cc8e7aafe184999c2037eb33c462b084a16ecb (diff)
downloadredot-engine-194b1c478d3868bf0cfb4edff93535ca484e643b.tar.gz
Merge pull request #92342 from aaronp64/textedit_duplication
Remove duplicate if/else code in `TextEdit::_notification`
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/text_edit.cpp23
1 files changed, 6 insertions, 17 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 69b84da23d..a36eb0652e 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1003,23 +1003,12 @@ void TextEdit::_notification(int p_what) {
}
}
- if (str.length() == 0) {
- // Draw line background if empty as we won't loop at all.
- if (caret_line_wrap_index_map.has(line) && caret_line_wrap_index_map[line].has(line_wrap_index) && highlight_current_line) {
- if (rtl) {
- RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
- } else {
- RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
- }
- }
- } else {
- // If it has text, then draw current line marker in the margin, as line number etc will draw over it, draw the rest of line marker later.
- if (caret_line_wrap_index_map.has(line) && caret_line_wrap_index_map[line].has(line_wrap_index) && highlight_current_line) {
- if (rtl) {
- RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
- } else {
- RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
- }
+ // Draw current line highlight.
+ if (highlight_current_line && caret_line_wrap_index_map.has(line) && caret_line_wrap_index_map[line].has(line_wrap_index)) {
+ if (rtl) {
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(size.width - ofs_x - xmargin_end, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
+ } else {
+ RenderingServer::get_singleton()->canvas_item_add_rect(ci, Rect2(ofs_x, ofs_y, xmargin_end, row_height), theme_cache.current_line_color);
}
}