mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-20 17:39:58 +03:00
textarea: always clear selection on NS_KEY_WORD_{LEFT,RIGHT}
This bug can be seen by selecting some text starting from the beginning of a textarea (so that caret is 0) and then pressing the NS_KEY_WORD_LEFT binding. NS_KEY_WORD_LEFT was breaking early when caret was 0. So, to always clear the selection, the clear selection code has been brought above the break statement. NS_KEY_WORD_RIGHT did not have such a break statement, so one has been added for consistency, and because string operations are expensive.
This commit is contained in:
parent
88d5ea8668
commit
4fc78449ff
@ -2743,6 +2743,9 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
|
||||
case NS_KEY_WORD_LEFT:
|
||||
if (readonly)
|
||||
break;
|
||||
if (ta->sel_start != -1) {
|
||||
textarea_clear_selection(ta);
|
||||
}
|
||||
if (caret == 0)
|
||||
break;
|
||||
caret--;
|
||||
@ -2756,9 +2759,6 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ta->sel_start != -1) {
|
||||
textarea_clear_selection(ta);
|
||||
}
|
||||
break;
|
||||
case NS_KEY_DELETE_WORD_LEFT:
|
||||
if (readonly)
|
||||
@ -2807,6 +2807,11 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
|
||||
case NS_KEY_WORD_RIGHT:
|
||||
if (readonly)
|
||||
break;
|
||||
if (ta->sel_start != -1) {
|
||||
textarea_clear_selection(ta);
|
||||
}
|
||||
if (caret == ta->show->len - 1)
|
||||
break;
|
||||
if (strchr(sep, ta->show->data[caret]) != NULL &&
|
||||
caret < ta->show->len - 1) {
|
||||
while (strchr(sep, ta->show->data[caret]) !=
|
||||
@ -2823,9 +2828,6 @@ bool textarea_keypress(struct textarea *ta, uint32_t key)
|
||||
while (strchr(sep, ta->show->data[caret]) != NULL &&
|
||||
caret < ta->show->len - 1)
|
||||
caret++;
|
||||
if (ta->sel_start != -1) {
|
||||
textarea_clear_selection(ta);
|
||||
}
|
||||
break;
|
||||
case NS_KEY_DELETE_WORD_RIGHT:
|
||||
if (readonly)
|
||||
|
Loading…
Reference in New Issue
Block a user