diff options
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r-- | scene/gui/text_edit.cpp | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 6b5ff23436..b8bb17eb2a 100644 --- a/scene/gui/text_edit.cpp +++ b/scene/gui/text_edit.cpp @@ -332,6 +332,7 @@ void TextEdit::Text::clear() { max_line_width_dirty = true; max_line_height_dirty = true; + total_visible_line_count = 0; Line line; line.gutters.resize(gutter_count); @@ -421,6 +422,10 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { for (int i = p_from_line; i < p_to_line; i++) { const Line &text_line = text[i]; + if (text_line.hidden) { + continue; + } + if (text_line.height == max_line_height) { max_line_height_dirty = true; } @@ -435,6 +440,8 @@ void TextEdit::Text::remove_range(int p_from_line, int p_to_line) { text.write[(i - diff) + 1] = text[i + 1]; } text.resize(text.size() - diff); + + ERR_FAIL_COND(total_visible_line_count < 0); // BUG } void TextEdit::Text::add_gutter(int p_at) { @@ -3169,6 +3176,7 @@ bool TextEdit::has_ime_text() const { void TextEdit::cancel_ime() { if (!has_ime_text()) { + _close_ime_window(); return; } ime_text = String(); @@ -3181,6 +3189,7 @@ void TextEdit::cancel_ime() { void TextEdit::apply_ime() { if (!has_ime_text()) { + _close_ime_window(); return; } @@ -4166,7 +4175,7 @@ void TextEdit::redo() { } _push_current_op(); - if (undo_stack_pos == nullptr) { + if (!has_redo()) { return; // Nothing to do. } @@ -5069,7 +5078,7 @@ bool TextEdit::multicaret_edit_ignore_caret(int p_caret) const { } bool TextEdit::is_caret_visible(int p_caret) const { - ERR_FAIL_INDEX_V(p_caret, carets.size(), 0); + ERR_FAIL_INDEX_V(p_caret, carets.size(), false); return carets[p_caret].visible; } @@ -5736,7 +5745,7 @@ TextServer::AutowrapMode TextEdit::get_autowrap_mode() const { } bool TextEdit::is_line_wrapped(int p_line) const { - ERR_FAIL_INDEX_V(p_line, text.size(), 0); + ERR_FAIL_INDEX_V(p_line, text.size(), false); if (get_line_wrapping_mode() == LineWrappingMode::LINE_WRAPPING_NONE) { return false; } @@ -7301,6 +7310,10 @@ void TextEdit::_paste_internal(int p_caret) { } String clipboard = DisplayServer::get_singleton()->clipboard_get(); + if (clipboard.is_empty()) { + // Nothing to paste. + return; + } // Paste a full line. Ignore '\r' characters that may have been added to the clipboard by the OS. if (get_caret_count() == 1 && !has_selection(0) && !cut_copy_line.is_empty() && cut_copy_line == clipboard.replace("\r", "")) { |