summaryrefslogtreecommitdiff
path: root/LibGUI
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-04-25 01:28:17 +0200
committerAndreas Kling <awesomekling@gmail.com>2019-04-25 01:28:17 +0200
commit2c51bc92afd4a379d8032a5fe9b919bb2354bef3 (patch)
tree9c08854d5e788c4405df2d3b9fb4f3b5f23537fd /LibGUI
parent4e715dbc71a7556fc97f780d335a03382e33eb8e (diff)
downloadserenity-2c51bc92afd4a379d8032a5fe9b919bb2354bef3.zip
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().
Diffstat (limited to 'LibGUI')
-rw-r--r--LibGUI/GTextEditor.cpp16
1 files changed, 7 insertions, 9 deletions
diff --git a/LibGUI/GTextEditor.cpp b/LibGUI/GTextEditor.cpp
index be027349b2..0b350fb51e 100644
--- a/LibGUI/GTextEditor.cpp
+++ b/LibGUI/GTextEditor.cpp
@@ -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)