summaryrefslogtreecommitdiff
path: root/scene/gui/text_edit.cpp
diff options
context:
space:
mode:
authornova++ <3247833+novaplusplus@users.noreply.github.com>2022-03-10 20:25:59 -0500
committerNova <3247833+novaplusplus@users.noreply.github.com>2022-03-11 01:13:45 -0500
commit4b8fa3716f384064382fc0c7cb7bb91fde1626e0 (patch)
treebaa76e41baae689bc412c6d256d16926e84242fb /scene/gui/text_edit.cpp
parent7866c984798de62cbb9028f3d1eee947809e0aa9 (diff)
Fix "p_from_line > p_to_line" errors in text edit
Done via making the function more robust to different inputs
Diffstat (limited to 'scene/gui/text_edit.cpp')
-rw-r--r--scene/gui/text_edit.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 05fda7128c..3c80e3f987 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4469,7 +4469,11 @@ int TextEdit::get_visible_line_count() const {
int TextEdit::get_visible_line_count_in_range(int p_from_line, int p_to_line) const {
ERR_FAIL_INDEX_V(p_from_line, text.size(), 0);
ERR_FAIL_INDEX_V(p_to_line, text.size(), 0);
- ERR_FAIL_COND_V(p_from_line > p_to_line, 0);
+
+ // So we can handle inputs in whatever order
+ if (p_from_line > p_to_line) {
+ SWAP(p_from_line, p_to_line);
+ }
/* Returns the total number of (lines + wrapped - hidden). */
if (!_is_hiding_enabled() && get_line_wrapping_mode() == LineWrappingMode::LINE_WRAPPING_NONE) {