From 20df82c9830d1b4ee76bb2d589b5221ee5381c10 Mon Sep 17 00:00:00 2001 From: FalseHonesty Date: Sat, 23 May 2020 13:03:31 -0400 Subject: [PATCH] Browser: Set the console's interpreter when a tab's document changes Previously, once a console was opened for a tab, its interpreter would never change, leaving it with a stale interpreter. Now, when the tab's HtmlView loads a new document, the console will receive that document's interpreter. --- Applications/Browser/Tab.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Applications/Browser/Tab.cpp b/Applications/Browser/Tab.cpp index eaee09a8ebd..21b0ee662a6 100644 --- a/Applications/Browser/Tab.cpp +++ b/Applications/Browser/Tab.cpp @@ -206,6 +206,13 @@ Tab::Tab() on_favicon_change(icon); }; + m_html_widget->on_set_document = [this](auto* document) { + if (document && m_console_window) { + auto* console_widget = static_cast(m_console_window->main_widget()); + console_widget->set_interpreter(document->interpreter().make_weak_ptr()); + } + }; + auto focus_location_box_action = GUI::Action::create( "Focus location box", { Mod_Ctrl, Key_L }, [this](auto&) { m_location_box->select_all();