Merge pull request #92342 from aaronp64/textedit_duplication

Remove duplicate if/else code in `TextEdit::_notification`
This commit is contained in:
Rémi Verschelde 2024-05-28 15:49:19 +02:00
commit 194b1c478d
No known key found for this signature in database
GPG key ID: C3336907360768E1

View file

@ -1003,25 +1003,14 @@ 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) {
// 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);
}
}
} 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);
}
}
}
if (line_wrap_index == 0) {
// Only do these if we are on the first wrapped part of a line.