mirror of
https://github.com/SerenityOS/serenity.git
synced 2025-01-24 10:22:05 -05:00
GTextEditor: Fixed bug on KeyCode::Key_Right pressed.
Pressing right did nothing when the very last characters of the buffer were selected. The expected action would be for the cursor to move to the end of the buffer. This patch fixes that.
This commit is contained in:
parent
b50ffaf7e1
commit
ed0553fe10
1 changed files with 13 additions and 16 deletions
|
@ -545,24 +545,21 @@ void GTextEditor::keydown_event(GKeyEvent& event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.key() == KeyCode::Key_Right) {
|
if (event.key() == KeyCode::Key_Right) {
|
||||||
|
int new_line = m_cursor.line();
|
||||||
|
int new_column = m_cursor.column();
|
||||||
if (m_cursor.column() < current_line().length()) {
|
if (m_cursor.column() < current_line().length()) {
|
||||||
int new_column = m_cursor.column() + 1;
|
new_line = m_cursor.line();
|
||||||
toggle_selection_if_needed_for_event(event);
|
new_column = m_cursor.column() + 1;
|
||||||
set_cursor(m_cursor.line(), new_column);
|
|
||||||
if (m_selection.start().is_valid()) {
|
|
||||||
m_selection.set_end(m_cursor);
|
|
||||||
did_update_selection();
|
|
||||||
}
|
|
||||||
} else if (m_cursor.line() != line_count() - 1) {
|
} else if (m_cursor.line() != line_count() - 1) {
|
||||||
int new_line = m_cursor.line() + 1;
|
new_line = m_cursor.line() + 1;
|
||||||
int new_column = 0;
|
new_column = 0;
|
||||||
toggle_selection_if_needed_for_event(event);
|
}
|
||||||
set_cursor(new_line, new_column);
|
toggle_selection_if_needed_for_event(event);
|
||||||
if (m_selection.start().is_valid()) {
|
set_cursor(new_line, new_column);
|
||||||
m_selection.set_end(m_cursor);
|
if (m_selection.start().is_valid()) {
|
||||||
did_update_selection();
|
m_selection.set_end(m_cursor);
|
||||||
}
|
did_update_selection();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!event.ctrl() && event.key() == KeyCode::Key_Home) {
|
if (!event.ctrl() && event.key() == KeyCode::Key_Home) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue