1
0
mirror of https://github.com/irssi/irssi.git synced 2024-12-04 14:46:39 -05:00

Handle a paste start marker right after an end one (ignore both)

This actually workarounds a bug with the "st" terminal, for which i've
already submitted a patch, but irssi needs to be able to handle it
decently too.
This commit is contained in:
dequis 2015-09-25 03:09:14 -03:00
parent 7d062a313a
commit c721d57688

View File

@ -681,7 +681,8 @@ static void paste_bracketed_end(int i, gboolean rest)
static void paste_bracketed_middle()
{
int i;
int len = paste_buffer->len - G_N_ELEMENTS(bp_end);
int marklen = G_N_ELEMENTS(bp_end);
int len = paste_buffer->len - marklen;
unichar *ptr = (unichar *) paste_buffer->data;
if (len <= 0) {
@ -690,6 +691,23 @@ static void paste_bracketed_middle()
for (i = 0; i <= len; i++, ptr++) {
if (ptr[0] == bp_end[0] && memcmp(ptr, bp_end, sizeof(bp_end)) == 0) {
/* if there are at least 6 bytes after the end,
* check for another start marker right afterwards */
if (i <= (len - marklen) &&
memcmp(ptr + marklen, bp_start, sizeof(bp_start)) == 0) {
/* remove both markers*/
g_array_remove_range(paste_buffer, i, marklen * 2);
len -= marklen * 2;
/* go one step back */
if (i > 0) {
i--;
ptr--;
}
continue;
}
paste_bracketed_end(i, i != len);
break;
}