From c587db387c8edd27fc6ed9ed8c7bdbb6588e5264 Mon Sep 17 00:00:00 2001 From: Ben Wiederhake Date: Sat, 29 Aug 2020 13:44:25 +0200 Subject: [PATCH] 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. --- Applications/TextEditor/TextEditorWidget.cpp | 19 +++++++++---------- Applications/TextEditor/TextEditorWidget.h | 1 + 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Applications/TextEditor/TextEditorWidget.cpp b/Applications/TextEditor/TextEditorWidget.cpp index a69a8797c95..75396a36d58 100644 --- a/Applications/TextEditor/TextEditorWidget.cpp +++ b/Applications/TextEditor/TextEditorWidget.cpp @@ -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(); 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(); - 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()); +} diff --git a/Applications/TextEditor/TextEditorWidget.h b/Applications/TextEditor/TextEditorWidget.h index 54be8fcff12..77da7c5eae3 100644 --- a/Applications/TextEditor/TextEditorWidget.h +++ b/Applications/TextEditor/TextEditorWidget.h @@ -60,6 +60,7 @@ private: void update_preview(); void update_markdown_preview(); void update_html_preview(); + void update_statusbar_cursor_position(); virtual void drop_event(GUI::DropEvent&) override;