From 6d2dc774947787dcef73a3251d1e9ec51bc526df Mon Sep 17 00:00:00 2001 From: Berke Güzel Date: Thu, 15 Oct 2026 12:42:11 +0300 Subject: Report selection allocation failure instead of truncating On a screen taller than 256 rows the selection's row list is allocated. When that failed, it fell back to the 256-entry stack array, so the selection and the snapshot's selection spans silently stopped at row 256 while every call still reported success. lines_init() now reports the failure. term_select_start() and term_select_extend() return false and leave the selection unchanged, term_snapshot_update() fails and keeps its previous content, and the text getters return NULL, as they do for their other allocations. Co-Authored-By: Claude Opus 5.5 --- include/term/term.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/term/term.h b/include/term/term.h index c69e88e..8b98a25 100644 --- a/include/term/term.h +++ b/include/term/term.h @@ -336,11 +336,13 @@ enum term_select_unit { }; /* Start a selection at cell. For TERM_SELECT_CELL, right_half means the - * pointer is on the right half of the cell, so the selection starts after it. */ -TERM_API void term_select_start(struct term *t, struct term_vector2i cell, bool right_half, + * pointer is on the right half of the cell, so the selection starts after it. + * Returns false when memory runs out; the selection is then unchanged. */ +TERM_API bool term_select_start(struct term *t, struct term_vector2i cell, bool right_half, enum term_select_unit unit); -/* Extend the selection from its start to cell. */ -TERM_API void term_select_extend(struct term *t, struct term_vector2i cell, bool right_half); +/* Extend the selection from its start to cell. Returns false when memory runs + * out; the selection is then unchanged. */ +TERM_API bool term_select_extend(struct term *t, struct term_vector2i cell, bool right_half); TERM_API void term_select_clear(struct term *t); TERM_API bool term_has_selection(const struct term *t); /* Owned, NUL-terminated UTF-8 of the selection. NULL when nothing is -- cgit v1.2.3