mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 22:31:05 +00:00
[console] Don't overwrite tail line if same as current line
This fixes the current line object getting corrupted by the tail line update when the buffer is filled with a single line. There are probably more tests to write and bugs to fix :)
This commit is contained in:
parent
d13df6cd37
commit
9a92496662
2 changed files with 10 additions and 7 deletions
|
@ -91,19 +91,18 @@ Con_BufferAddText (con_buffer_t *buf, const char *text)
|
|||
len = buf->buffer_size;
|
||||
}
|
||||
while (len--) {
|
||||
byte c = *pos++ = *text++;
|
||||
if (pos >= buf->buffer + buf->buffer_size)
|
||||
pos = buf->buffer;
|
||||
cur_line->len++;
|
||||
if (pos == tail_line->text) {
|
||||
if (buf->num_lines > 0)
|
||||
buf->num_lines--;
|
||||
if (buf->num_lines > 1 && pos == tail_line->text) {
|
||||
buf->num_lines--;
|
||||
tail_line->text = 0;
|
||||
tail_line->len = 0;
|
||||
tail_line++;
|
||||
if (tail_line - buf->lines >= buf->max_lines)
|
||||
tail_line = buf->lines;
|
||||
}
|
||||
byte c = *pos++ = *text++;
|
||||
if (pos >= buf->buffer + buf->buffer_size)
|
||||
pos = buf->buffer;
|
||||
cur_line->len++;
|
||||
if (c == '\n') {
|
||||
if (buf->num_lines < buf->max_lines)
|
||||
buf->num_lines++;
|
||||
|
|
|
@ -91,6 +91,10 @@ test_2 (void)
|
|||
con->lines[con->cur_line].len);
|
||||
goto fail;
|
||||
}
|
||||
if (memcmp (con->buffer, text + 1024, 1024)) {
|
||||
printf ("con_buffer incorrect\n");
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
fail:
|
||||
|
|
Loading…
Reference in a new issue