diff options
| author | Daniel Eklöf <daniel@ekloef.se> | 2020-01-04 12:19:30 +0000 |
|---|---|---|
| committer | Daniel Eklöf <daniel@ekloef.se> | 2020-01-04 12:19:30 +0000 |
| commit | 6ee86be1bf881f99533cc660123c6992f19f20f4 (patch) | |
| tree | 435d1ac3c0e2d273dfe1cfe42718819b77b7db33 | |
| parent | selection: simplify extraction by converting to UTF-8 at the end (diff) | |
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.
| -rw-r--r-- | selection.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/selection.c b/selection.c index f81fcc85..b241d375 100644 --- a/selection.c +++ b/selection.c @@ -211,19 +211,21 @@ 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++; + ctx->last_row = row; + ctx->last_cell = cell; + return; + } - 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; + /* 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; - } + assert(ctx->idx + 1 <= ctx->size); + ctx->buf[ctx->idx++] = cell->wc; ctx->last_row = row; ctx->last_cell = cell; |
