mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 19:15:07 +00:00
TextEditor: Don't try to move(lambda)
The move constructor of a lambda just copies it anyway. Even if the first move() left an 'empty' closure behind, then 'm_editor->on_cursor_change' would only be able to see an empty closure, which is certainly not what was intended.
This commit is contained in:
parent
db422fa499
commit
c587db387c
2 changed files with 10 additions and 10 deletions
|
@ -86,15 +86,9 @@ TextEditorWidget::TextEditorWidget()
|
|||
update_title();
|
||||
};
|
||||
|
||||
auto update_statusbar_cursor_position = [this] {
|
||||
StringBuilder builder;
|
||||
builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
|
||||
m_statusbar->set_text(builder.to_string());
|
||||
};
|
||||
|
||||
m_page_view = splitter.add<Web::InProcessWebView>();
|
||||
m_page_view->set_visible(false);
|
||||
m_page_view->on_link_hover = [this, update_statusbar_cursor_position = move(update_statusbar_cursor_position)](auto& url) {
|
||||
m_page_view->on_link_hover = [this](auto& url) {
|
||||
if (url.is_valid())
|
||||
m_statusbar->set_text(url.to_string());
|
||||
else
|
||||
|
@ -300,9 +294,7 @@ TextEditorWidget::TextEditorWidget()
|
|||
|
||||
m_statusbar = add<GUI::StatusBar>();
|
||||
|
||||
m_editor->on_cursor_change = [update_statusbar_cursor_position = move(update_statusbar_cursor_position)] {
|
||||
update_statusbar_cursor_position();
|
||||
};
|
||||
m_editor->on_cursor_change = [this] { update_statusbar_cursor_position(); };
|
||||
|
||||
m_new_action = GUI::Action::create("New", { Mod_Ctrl, Key_N }, Gfx::Bitmap::load_from_file("/res/icons/16x16/new.png"), [this](const GUI::Action&) {
|
||||
if (m_document_dirty) {
|
||||
|
@ -643,3 +635,10 @@ void TextEditorWidget::update_html_preview()
|
|||
m_page_view->load_html(m_editor->text(), URL::create_with_file_protocol(m_path));
|
||||
m_page_view->scroll_into_view(current_scroll_pos, true, true);
|
||||
}
|
||||
|
||||
void TextEditorWidget::update_statusbar_cursor_position()
|
||||
{
|
||||
StringBuilder builder;
|
||||
builder.appendf("Line: %d, Column: %d", m_editor->cursor().line() + 1, m_editor->cursor().column());
|
||||
m_statusbar->set_text(builder.to_string());
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue