Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 11 additions & 19 deletions src/common/predefinedcommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

class AddCommandDialog final
{
Q_DECLARE_TR_FUNCTIONS(AddCommandDialog)

Check warning on line 25 in src/common/predefinedcommands.cpp

View workflow job for this annotation

GitHub Actions / Linux-Clang

unused member function 'trUtf8' [-Wunused-member-function]
};

} // namespace
Expand All @@ -48,35 +48,27 @@
c->icon = QString(QChar(IconCircleExclamation));
c->cmd = R"(function hasEmptyOrSingleCharText() {
if (dataFormats().includes(mimeText)) {
var text = str(data(mimeText));
if (text.match(/^\s*.?\s*$/)) {
const text = str(data(mimeText));
if (/^\s*.?\s*$/.test(text)) {
serverLog('Ignoring text with single or no character');
return true;
}
}
return false;
}

var onClipboardChanged_ = onClipboardChanged;
onClipboardChanged = function() {
if (!hasEmptyOrSingleCharText()) {
onClipboardChanged_();
}
}

var synchronizeFromSelection_ = synchronizeFromSelection;
synchronizeFromSelection = function() {
if (!hasEmptyOrSingleCharText()) {
synchronizeFromSelection_();
function overrideFunction(fn) {
const oldFn = global[fn];
global[fn] = function() {
if (!hasEmptyOrSingleCharText()) {
oldFn();
}
}
}

var synchronizeToSelection_ = synchronizeToSelection;
synchronizeToSelection = function() {
if (!hasEmptyOrSingleCharText()) {
synchronizeToSelection_();
}
}
overrideFunction('onClipboardChanged');
overrideFunction('provideClipboard');
overrideFunction('provideSelection');
)";
c->isScript = true;

Expand Down
Loading