mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-24 01:40:12 -05:00
selection: ensure start < end in finalize
When the selection is finalized, swap start/end if necessary, to make sure start <= end.
This commit is contained in:
parent
a82f12dd2b
commit
1e08d93528
2 changed files with 27 additions and 30 deletions
17
selection.c
17
selection.c
|
|
@ -30,12 +30,6 @@ extract_selection(const struct terminal *term)
|
|||
const struct coord *start = &term->selection.start;
|
||||
const struct coord *end = &term->selection.end;
|
||||
|
||||
if (start->row > end->row || (start->row == end->row && start->col > end->col)) {
|
||||
const struct coord *tmp = start;
|
||||
start = end;
|
||||
end = tmp;
|
||||
}
|
||||
|
||||
assert(start->row <= end->row);
|
||||
|
||||
size_t max_cells = 0;
|
||||
|
|
@ -159,6 +153,17 @@ selection_finalize(struct terminal *term, uint32_t serial)
|
|||
assert(term->selection.start.row != -1);
|
||||
assert(term->selection.end.row != -1);
|
||||
|
||||
if (term->selection.start.row > term->selection.end.row ||
|
||||
(term->selection.start.row == term->selection.end.row &&
|
||||
term->selection.start.col > term->selection.end.col))
|
||||
{
|
||||
struct coord tmp = term->selection.start;
|
||||
term->selection.start = term->selection.end;
|
||||
term->selection.end = tmp;
|
||||
}
|
||||
|
||||
assert(term->selection.start.row <= term->selection.end.row);
|
||||
|
||||
/* TODO: somehow share code with the clipboard equivalent */
|
||||
if (term->selection.primary.data_source != NULL) {
|
||||
/* Kill previous data source */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue