1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 02:27:43 +00:00

LibLine: Skip initial non-alphanumeric chars in cursor_right_word()

This commit is contained in:
ronak69 2024-01-03 10:56:16 +00:00 committed by Ali Mohammad Pur
parent b22be93e66
commit a6ce86a4b3

View file

@ -105,17 +105,17 @@ void Editor::cursor_left_character()
void Editor::cursor_right_word() void Editor::cursor_right_word()
{ {
if (m_cursor < m_buffer.size()) { auto has_seen_alnum = false;
// Temporarily put a space at the end of our buffer, while (m_cursor < m_buffer.size()) {
// doing this greatly simplifies the logic below. // after seeing at least one alnum, stop at the first non-alnum
m_buffer.append(' '); if (not is_ascii_alphanumeric(m_buffer[m_cursor])) {
for (;;) { if (has_seen_alnum)
if (m_cursor >= m_buffer.size())
break;
if (!is_ascii_alphanumeric(m_buffer[++m_cursor]))
break; break;
} else {
has_seen_alnum = true;
} }
m_buffer.take_last();
++m_cursor;
} }
m_inline_search_cursor = m_cursor; m_inline_search_cursor = m_cursor;
m_search_offset = 0; m_search_offset = 0;