mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-15 16:48:24 +03: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
Notes:
sideshowbarker
2024-07-19 03:00:38 +09:00
Author: https://github.com/BenWiederhake Commit: https://github.com/SerenityOS/serenity/commit/c587db387c8 Pull-request: https://github.com/SerenityOS/serenity/pull/3343 Reviewed-by: https://github.com/alimpfard Reviewed-by: https://github.com/awesomekling Reviewed-by: https://github.com/tomuta
@ -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());
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user