Skip to content

Commit 1cf8c0a

Browse files
committed
Fixed a bug in NumberedTextEditor that was copying all text when hitting
Ctrl+C when there was only a portion of the text selected (issue #2047)
1 parent b0f6b5c commit 1cf8c0a

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

libs/libgui/src/widgets/numberedtexteditor.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <QClipboard>
2929
#include "messagebox.h"
3030
#include "utilsns.h"
31+
#include <QTextDocumentFragment>
3132

3233
bool NumberedTextEditor::line_nums_visible {true};
3334
bool NumberedTextEditor::highlight_lines {true};
@@ -199,7 +200,10 @@ NumberedTextEditor::NumberedTextEditor(QWidget * parent, bool act_btns_enabled,
199200
connect(edit_src_btn, &QToolButton::clicked, this, __slot(this, NumberedTextEditor::editSource));
200201

201202
connect(copy_btn, &QToolButton::clicked, this, [this](){
202-
qApp->clipboard()->setText(toPlainText());
203+
if(textCursor().hasSelection())
204+
qApp->clipboard()->setText(textCursor().selection().toPlainText());
205+
else
206+
qApp->clipboard()->setText(toPlainText());
203207
});
204208

205209
connect(search_btn, &QToolButton::toggled, this, [this](bool checked){

0 commit comments

Comments
 (0)