properly record line info on empty lines

This commit is contained in:
ailin-nemui 2018-08-21 00:31:12 +02:00
commit a19b503a31
3 changed files with 18 additions and 7 deletions

View file

@ -307,9 +307,15 @@ static void sig_gui_print_text(WINDOW_REC *window, void *fgcolor,
}
textbuffer_line_add_colors(view->buffer, &insert_after, fg, bg, flags);
insert_after = textbuffer_insert(view->buffer, insert_after,
(unsigned char *) str,
strlen(str), &lineinfo);
/* for historical reasons, the \n will set
GUI_PRINT_FLAG_NEWLINE and print an empty string. in this
special case, ignore the empty string which would otherwise
start another new line */
if (~flags & GUI_PRINT_FLAG_NEWLINE || *str != '\0') {
insert_after = textbuffer_insert(view->buffer, insert_after, (unsigned char *) str,
strlen(str), &lineinfo);
}
if (gui->use_insert_after)
gui->insert_after = insert_after;
}

View file

@ -333,8 +333,9 @@ void textbuffer_line_add_colors(TEXT_BUFFER_REC *buffer, LINE_REC **line,
data[pos++] = LINE_CMD_INDENT;
}
if (pos > 0)
if (pos > 0) {
*line = textbuffer_insert(buffer, *line, data, pos, NULL);
}
buffer->last_flags = flags;
}
@ -355,9 +356,6 @@ LINE_REC *textbuffer_insert(TEXT_BUFFER_REC *buffer, LINE_REC *insert_after,
g_return_val_if_fail(buffer != NULL, NULL);
g_return_val_if_fail(data != NULL, NULL);
if (len == 0)
return insert_after;
line = !buffer->last_eol ? insert_after :
textbuffer_line_insert(buffer, insert_after);