mirror of
https://github.com/RGBCube/serenity
synced 2025-05-20 11:55:08 +00:00
GTextEditor: Always call did_change() before set_cursor().
This is not very obvious and I need to come up with a better design, but for now just make sure to call did_change() before calling set_cursor(). This is needed because set_cursor() will try to scroll the cursor into view, and for right-aligned text, did_change() may change the content rect which needs to be reflected by the time we call scroll_cursor_into_view().
This commit is contained in:
parent
4e715dbc71
commit
2c51bc92af
1 changed files with 7 additions and 9 deletions
|
@ -496,8 +496,8 @@ void GTextEditor::do_delete()
|
|||
if (m_cursor.column() < current_line().length()) {
|
||||
// Delete within line
|
||||
current_line().remove(m_cursor.column());
|
||||
update_cursor();
|
||||
did_change();
|
||||
update_cursor();
|
||||
return;
|
||||
}
|
||||
if (m_cursor.column() == current_line().length() && m_cursor.line() != line_count() - 1) {
|
||||
|
@ -507,8 +507,8 @@ void GTextEditor::do_delete()
|
|||
current_line().append(next_line.characters(), next_line.length());
|
||||
m_lines.remove(m_cursor.line() + 1);
|
||||
update();
|
||||
set_cursor(m_cursor.line(), previous_length);
|
||||
did_change();
|
||||
set_cursor(m_cursor.line(), previous_length);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -534,8 +534,8 @@ void GTextEditor::insert_at_cursor(char ch)
|
|||
if (at_tail || at_head) {
|
||||
m_lines.insert(m_cursor.line() + (at_tail ? 1 : 0), make<Line>());
|
||||
update();
|
||||
set_cursor(m_cursor.line() + 1, 0);
|
||||
did_change();
|
||||
set_cursor(m_cursor.line() + 1, 0);
|
||||
return;
|
||||
}
|
||||
auto new_line = make<Line>();
|
||||
|
@ -543,8 +543,8 @@ void GTextEditor::insert_at_cursor(char ch)
|
|||
current_line().truncate(m_cursor.column());
|
||||
m_lines.insert(m_cursor.line() + 1, move(new_line));
|
||||
update();
|
||||
set_cursor(m_cursor.line() + 1, 0);
|
||||
did_change();
|
||||
set_cursor(m_cursor.line() + 1, 0);
|
||||
return;
|
||||
}
|
||||
if (ch == '\t') {
|
||||
|
@ -553,15 +553,13 @@ void GTextEditor::insert_at_cursor(char ch)
|
|||
for (int i = 0; i < spaces_to_insert; ++i) {
|
||||
current_line().insert(m_cursor.column(), ' ');
|
||||
}
|
||||
set_cursor(m_cursor.line(), next_soft_tab_stop);
|
||||
update_cursor();
|
||||
did_change();
|
||||
set_cursor(m_cursor.line(), next_soft_tab_stop);
|
||||
return;
|
||||
}
|
||||
current_line().insert(m_cursor.column(), ch);
|
||||
set_cursor(m_cursor.line(), m_cursor.column() + 1);
|
||||
update_cursor();
|
||||
did_change();
|
||||
set_cursor(m_cursor.line(), m_cursor.column() + 1);
|
||||
}
|
||||
|
||||
int GTextEditor::content_x_for_position(const GTextPosition& position) const
|
||||
|
@ -862,9 +860,9 @@ void GTextEditor::delete_selection()
|
|||
|
||||
m_selection.clear();
|
||||
did_update_selection();
|
||||
did_change();
|
||||
set_cursor(selection.start());
|
||||
update();
|
||||
did_change();
|
||||
}
|
||||
|
||||
void GTextEditor::insert_at_cursor_or_replace_selection(const String& text)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue