mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-04 04:06:06 -05:00
extract: ensure line-based selections are terminated with a newline
Closes #869
This commit is contained in:
parent
5ee902551a
commit
69e2bff8c8
2 changed files with 20 additions and 3 deletions
|
|
@ -80,6 +80,8 @@
|
|||
(https://codeberg.org/dnkl/foot/issues/900).
|
||||
* File pasted, or dropped, on the alt screen is no longer quoted
|
||||
(https://codeberg.org/dnkl/foot/issues/379).
|
||||
* Line-based selections now include a trailing newline when copied
|
||||
(https://codeberg.org/dnkl/foot/issues/869).
|
||||
|
||||
|
||||
### Deprecated
|
||||
|
|
|
|||
21
extract.c
21
extract.c
|
|
@ -86,9 +86,24 @@ extract_finish_wide(struct extraction_context *ctx, wchar_t **text, size_t *len)
|
|||
} else {
|
||||
xassert(ctx->idx > 0);
|
||||
xassert(ctx->idx <= ctx->size);
|
||||
if (ctx->buf[ctx->idx - 1] == L'\n')
|
||||
ctx->buf[ctx->idx - 1] = L'\0';
|
||||
else {
|
||||
|
||||
switch (ctx->selection_kind) {
|
||||
default:
|
||||
if (ctx->buf[ctx->idx - 1] == L'\n')
|
||||
ctx->buf[ctx->idx - 1] = L'\0';
|
||||
break;
|
||||
|
||||
case SELECTION_LINE_WISE:
|
||||
if (ctx->buf[ctx->idx - 1] != L'\n') {
|
||||
if (!ensure_size(ctx, 1))
|
||||
goto err;
|
||||
ctx->buf[ctx->idx++] = L'\n';
|
||||
}
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (ctx->buf[ctx->idx - 1] != L'\0') {
|
||||
if (!ensure_size(ctx, 1))
|
||||
goto err;
|
||||
ctx->buf[ctx->idx++] = L'\0';
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue