mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-04-28 06:46:38 -04:00
selection: fix inconsistency in block selections
Previously, if you made a block selection, creating a single column would set the left/right direction of a selection. This meant that: 1. Creating a single column and then dragging right created a selection which excluded the original column 2. Dragging your selection left and right would create a selection two columns wide for two consecutive cells of cursor movement So, leave the selection as SELECTION_UNDIR when appropriate and only set a pivot when the start and end columns are different. This makes the behaviour the same as char-wise selections on a single line.
This commit is contained in:
parent
bd8dd9ff7e
commit
da942e8c2e
1 changed files with 7 additions and 4 deletions
11
selection.c
11
selection.c
|
|
@ -812,13 +812,16 @@ selection_update(struct terminal *term, int col, int row)
|
||||||
struct coord *pivot_end = &term->selection.pivot.end;
|
struct coord *pivot_end = &term->selection.pivot.end;
|
||||||
|
|
||||||
if (term->selection.kind == SELECTION_BLOCK) {
|
if (term->selection.kind == SELECTION_BLOCK) {
|
||||||
if (new_end.col > pivot_start->col)
|
if (new_end.col < pivot_start->col)
|
||||||
new_direction = SELECTION_RIGHT;
|
|
||||||
else
|
|
||||||
new_direction = SELECTION_LEFT;
|
new_direction = SELECTION_LEFT;
|
||||||
|
else if (new_end.col > pivot_start->col || new_direction == SELECTION_LEFT)
|
||||||
|
new_direction = SELECTION_RIGHT;
|
||||||
|
|
||||||
if (term->selection.direction == SELECTION_UNDIR)
|
if (term->selection.direction == SELECTION_UNDIR &&
|
||||||
|
new_end.col != new_start.col)
|
||||||
|
{
|
||||||
set_pivot_point_for_block_and_char_wise(term, *pivot_start, new_direction);
|
set_pivot_point_for_block_and_char_wise(term, *pivot_start, new_direction);
|
||||||
|
}
|
||||||
|
|
||||||
if (new_direction == SELECTION_LEFT)
|
if (new_direction == SELECTION_LEFT)
|
||||||
new_start = *pivot_end;
|
new_start = *pivot_end;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue