selection: replace \r\n with \n in pasted text

This commit is contained in:
Daniel Eklöf 2019-10-16 21:14:45 +02:00
parent bb0ce50b24
commit 3ca6f9fe0b
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -517,6 +517,14 @@ text_from_clipboard(struct terminal *term, uint32_t serial,
} else if (amount == 0)
break;
/* Replace \r\n with \n */
for (size_t i = 0; i < amount - 1; i++) {
if (text[i] == '\r' && text[i + 1] == '\n') {
memmove(&text[i], &text[i + 1], amount - i - 1);
amount--;
}
}
cb(text, amount, user);
}
@ -645,6 +653,14 @@ text_from_primary(
} else if (amount == 0)
break;
/* Replace \r\n with \n */
for (size_t i = 0; i < amount - 1; i++) {
if (text[i] == '\r' && text[i + 1] == '\n') {
memmove(&text[i], &text[i + 1], amount - i - 1);
amount--;
}
}
cb(text, amount, user);
}