Fix text edit wrapping beyond control size, issue 23896

This commit is contained in:
Paulb23 2019-01-05 16:58:54 +00:00
parent 021421e180
commit 411df08711
2 changed files with 6 additions and 4 deletions

View file

@ -549,16 +549,17 @@ void TextEdit::_notification(int p_what) {
MessageQueue::get_singleton()->push_call(this, "_cursor_changed_emit");
if (text_changed_dirty)
MessageQueue::get_singleton()->push_call(this, "_text_changed_emit");
update_wrap_at();
_update_wrap_at();
} break;
case NOTIFICATION_RESIZED: {
_update_scrollbars();
update_wrap_at();
call_deferred("_update_wrap_at");
} break;
case NOTIFICATION_THEME_CHANGED: {
_update_caches();
_update_wrap_at();
} break;
case MainLoop::NOTIFICATION_WM_FOCUS_IN: {
window_has_focus = true;
@ -3643,7 +3644,7 @@ int TextEdit::get_total_visible_rows() const {
return total_rows;
}
void TextEdit::update_wrap_at() {
void TextEdit::_update_wrap_at() {
wrap_at = get_size().width - cache.style_normal->get_minimum_size().width - cache.line_number_w - cache.breakpoint_gutter_width - cache.fold_gutter_width - wrap_right_offset;
update_cursor_wrap_offset();
@ -6091,6 +6092,7 @@ void TextEdit::_bind_methods() {
ClassDB::bind_method(D_METHOD("_click_selection_held"), &TextEdit::_click_selection_held);
ClassDB::bind_method(D_METHOD("_toggle_draw_caret"), &TextEdit::_toggle_draw_caret);
ClassDB::bind_method(D_METHOD("_v_scroll_input"), &TextEdit::_v_scroll_input);
ClassDB::bind_method(D_METHOD("_update_wrap_at"), &TextEdit::_update_wrap_at);
BIND_ENUM_CONSTANT(SEARCH_MATCH_CASE);
BIND_ENUM_CONSTANT(SEARCH_WHOLE_WORDS);

View file

@ -336,7 +336,7 @@ private:
int get_total_visible_rows() const;
void update_cursor_wrap_offset();
void update_wrap_at();
void _update_wrap_at();
bool line_wraps(int line) const;
int times_line_wraps(int line) const;
Vector<String> get_wrap_rows_text(int p_line) const;