summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2018-09-30 22:49:45 +0200
committerGitHub <noreply@github.com>2018-09-30 22:49:45 +0200
commit01e1c6e8b62e9686a0d950e8756a4ce7c45706ce (patch)
treed04eb0fcf3ba635c0768cddaf60d149c89060dbe
parentc23636fcdc281ce232177aee989f65fe69d2ce22 (diff)
parentf5f948210c584eb6599c097ce5fbeb9990f78cc7 (diff)
Merge pull request #22560 from lupoDharkael/clipboard
TextEdit: prevent the copy of an empty string
-rw-r--r--scene/gui/text_edit.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 9fe306c236..c390c60a8c 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4545,9 +4545,13 @@ void TextEdit::cut() {
void TextEdit::copy() {
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 {
String clipboard = _base_get_text(selection.from_line, selection.from_column, selection.to_line, selection.to_column);
OS::get_singleton()->set_clipboard(clipboard);