Browse Source

Merge pull request #22560 from lupoDharkael/clipboard

TextEdit: prevent the copy of an empty string
Rémi Verschelde 7 years ago
parent
commit
01e1c6e8b6
1 changed files with 7 additions and 3 deletions
  1. 7 3
      scene/gui/text_edit.cpp

+ 7 - 3
scene/gui/text_edit.cpp

@@ -4545,9 +4545,13 @@ void TextEdit::cut() {
 void TextEdit::copy() {
 void TextEdit::copy() {
 
 
 	if (!selection.active) {
 	if (!selection.active) {
-		String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
-		OS::get_singleton()->set_clipboard(clipboard);
-		cut_copy_line = clipboard;
+
+		if (text[cursor.line].length() != 0) {
+
+			String clipboard = _base_get_text(cursor.line, 0, cursor.line, text[cursor.line].length());
+			OS::get_singleton()->set_clipboard(clipboard);
+			cut_copy_line = clipboard;
+		}
 	} else {
 	} else {
 		String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
 		String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
 		OS::get_singleton()->set_clipboard(clipboard);
 		OS::get_singleton()->set_clipboard(clipboard);