Make arrow keys always move the cursor to the edge of the selection first #93
|
@ -3178,12 +3178,14 @@ oc_str32 oc_ui_edit_perform_operation(oc_ui_context* ui, oc_ui_edit_op operation
|
||||||
{
|
{
|
||||||
case OC_UI_EDIT_MOVE:
|
case OC_UI_EDIT_MOVE:
|
||||||
{
|
{
|
||||||
|
bool wasSelectionEmpty = ui->editCursor == ui->editMark;
|
||||||
|
|
||||||
//NOTE(martin): we place the cursor on the direction-most side of the selection
|
//NOTE(martin): we place the cursor on the direction-most side of the selection
|
||||||
// before performing the move
|
// before performing the move
|
||||||
u32 cursor = direction < 0 ? oc_min(ui->editCursor, ui->editMark) : oc_max(ui->editCursor, ui->editMark);
|
u32 cursor = direction < 0 ? oc_min(ui->editCursor, ui->editMark) : oc_max(ui->editCursor, ui->editMark);
|
||||||
ui->editCursor = cursor;
|
ui->editCursor = cursor;
|
||||||
|
|
||||||
if(ui->editCursor == ui->editMark || move != OC_UI_EDIT_MOVE_CHAR)
|
if(wasSelectionEmpty || move != OC_UI_EDIT_MOVE_CHAR)
|
||||||
{
|
{
|
||||||
//NOTE: we special case move-one when there is a selection
|
//NOTE: we special case move-one when there is a selection
|
||||||
// (just place the cursor at begining/end of selection)
|
// (just place the cursor at begining/end of selection)
|
||||||
|
|
Loading…
Reference in New Issue