mirror of
https://github.com/RGBCube/serenity
synced 2025-05-24 18:25:07 +00:00
LibLine: Skip initial non-alphanumeric chars in cursor_left_word()
This commit is contained in:
parent
5ace712282
commit
b22be93e66
1 changed files with 9 additions and 8 deletions
|
@ -78,16 +78,17 @@ void Editor::search_backwards()
|
||||||
|
|
||||||
void Editor::cursor_left_word()
|
void Editor::cursor_left_word()
|
||||||
{
|
{
|
||||||
if (m_cursor > 0) {
|
auto has_seen_alnum = false;
|
||||||
auto skipped_at_least_one_character = false;
|
while (m_cursor) {
|
||||||
for (;;) {
|
// after seeing at least one alnum, stop just before a non-alnum
|
||||||
if (m_cursor == 0)
|
if (not is_ascii_alphanumeric(m_buffer[m_cursor - 1])) {
|
||||||
|
if (has_seen_alnum)
|
||||||
break;
|
break;
|
||||||
if (skipped_at_least_one_character && !is_ascii_alphanumeric(m_buffer[m_cursor - 1])) // stop *after* a non-alnum, but only if it changes the position
|
} else {
|
||||||
break;
|
has_seen_alnum = true;
|
||||||
skipped_at_least_one_character = true;
|
|
||||||
--m_cursor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
--m_cursor;
|
||||||
}
|
}
|
||||||
m_inline_search_cursor = m_cursor;
|
m_inline_search_cursor = m_cursor;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue