summaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2018-01-03 10:30:51 +0100
committerGitHub <noreply@github.com>2018-01-03 10:30:51 +0100
commit592b0fc06858853508d99d72a8abc1423f940abb (patch)
tree4ac7a8e481892800a0b25c2d49ada9ee8eca9fbc /scene
parent6cd33f17f7aa25ca019f1c2496f68e191b348582 (diff)
parent076a5f35fc31375b5083cd86dcd69ae580eea8b9 (diff)
Merge pull request #15063 from poke1024/textedit-select-last-line
Fix key down on last line in TextEdit
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/text_edit.cpp30
-rw-r--r--scene/gui/text_edit.h1
2 files changed, 29 insertions, 2 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 2ce31ea1b3..836b11c349 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -2725,6 +2725,8 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
_scroll_lines_down();
break;
}
+
+ {
#else
if (k->get_command() && k->get_alt()) {
_scroll_lines_down();
@@ -2733,9 +2735,15 @@ void TextEdit::_gui_input(const Ref<InputEvent> &p_gui_input) {
if (k->get_command())
cursor_set_line(text.size() - 1, true, false);
- else
+ else {
#endif
- cursor_set_line(cursor_get_line() + num_lines_from(CLAMP(cursor.line + 1, 0, text.size() - 1), 1), true, false);
+ if (!is_last_visible_line(cursor.line)) {
+ cursor_set_line(cursor_get_line() + num_lines_from(CLAMP(cursor.line + 1, 0, text.size() - 1), 1), true, false);
+ } else {
+ cursor_set_line(text.size() - 1);
+ cursor_set_column(get_line(cursor.line).length(), true);
+ }
+ }
if (k->get_shift())
_post_shift_selection();
@@ -4584,6 +4592,24 @@ int TextEdit::num_lines_from(int p_line_from, int unhidden_amount) const {
return num_total;
}
+bool TextEdit::is_last_visible_line(int p_line) const {
+
+ ERR_FAIL_INDEX_V(p_line, text.size(), false);
+
+ if (p_line == text.size() - 1)
+ return true;
+
+ if (!is_hiding_enabled())
+ return false;
+
+ for (int i = p_line + 1; i < text.size(); i++) {
+ if (!is_line_hidden(i))
+ return false;
+ }
+
+ return true;
+}
+
int TextEdit::get_indent_level(int p_line) const {
ERR_FAIL_INDEX_V(p_line, text.size(), 0);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index 320bb6d9fd..ccd7ba8278 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -433,6 +433,7 @@ public:
void fold_all_lines();
void unhide_all_lines();
int num_lines_from(int p_line_from, int unhidden_amount) const;
+ bool is_last_visible_line(int p_line) const;
bool can_fold(int p_line) const;
bool is_folded(int p_line) const;
void fold_line(int p_line);