Browse Source

Merge pull request #16711 from xsellier/bugfix/ensure-clear-use-0-index

Clear function made godot crashing because line_number is below 0 (2.1.5-beta)
Rémi Verschelde 7 năm trước cách đây
mục cha
commit
a2d920703c
1 tập tin đã thay đổi với 1 bổ sung1 xóa
  1. 1 1
      scene/gui/text_edit.cpp

+ 1 - 1
scene/gui/text_edit.cpp

@@ -3212,7 +3212,7 @@ void TextEdit::_clear() {
 		op.type = TextOperation::TYPE_CLEAR;
 		op.from_line = 0;
 		op.from_column = 0;
-		op.to_line = get_line_count() - 1;
+		op.to_line = MAX(0, get_line_count() - 1);
 		op.to_column = get_line(op.to_line).length();
 		op.text = undo_text;
 		op.version = ++version;