mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-15 22:05:24 -05:00
selection: fix bug where first column on all rows but the first was lost
When extracting text from the selection, we lost the first column on all rows but the first. This is because the algorithm changed slightly when we moved to foreach_selection(); the end-of-line detection is now done on the first column of the new line, instead of the last column on the previous line.
This commit is contained in:
parent
e28cb989d8
commit
6ee86be1bf
1 changed files with 13 additions and 11 deletions
24
selection.c
24
selection.c
|
|
@ -211,20 +211,22 @@ extract_one(struct terminal *term, struct row *row, struct cell *cell,
|
|||
ctx->empty_count = 0;
|
||||
}
|
||||
|
||||
else if (cell->wc == 0)
|
||||
if (cell->wc == 0) {
|
||||
ctx->empty_count++;
|
||||
|
||||
else {
|
||||
/* Replace empty cells with spaces when followed by non-empty cell */
|
||||
assert(ctx->idx + ctx->empty_count <= ctx->size);
|
||||
for (size_t i = 0; i < ctx->empty_count; i++)
|
||||
ctx->buf[ctx->idx++] = L' ';
|
||||
ctx->empty_count = 0;
|
||||
|
||||
assert(ctx->idx + 1 <= ctx->size);
|
||||
ctx->buf[ctx->idx++] = cell->wc;
|
||||
ctx->last_row = row;
|
||||
ctx->last_cell = cell;
|
||||
return;
|
||||
}
|
||||
|
||||
/* Replace empty cells with spaces when followed by non-empty cell */
|
||||
assert(ctx->idx + ctx->empty_count <= ctx->size);
|
||||
for (size_t i = 0; i < ctx->empty_count; i++)
|
||||
ctx->buf[ctx->idx++] = L' ';
|
||||
ctx->empty_count = 0;
|
||||
|
||||
assert(ctx->idx + 1 <= ctx->size);
|
||||
ctx->buf[ctx->idx++] = cell->wc;
|
||||
|
||||
ctx->last_row = row;
|
||||
ctx->last_cell = cell;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue