Repository: microsoft/terminal
File: src/cascadia/TerminalControl/TermControl.cpp (C++)

Code before:
                Windows::UI::Xaml::Controls::Canvas::SetTop(r, relativePos);
                if (rightAlign)
                {
                    Windows::UI::Xaml::Controls::Canvas::SetLeft(r, 16.0f * .66f);
                }
            };

            for (const auto m : marks)
            {
                Windows::UI::Xaml::Shapes::Rectangle r;
                Media::SolidColorBrush brush{};
                // Sneaky: technically, a mark doesn't need to have a color set,
                // it might want to just use the color from the palette for that
                // kind of mark. Fortunately, ControlCore is kind enough to
                // pre-evaluate that for us, and shove the real value into the
                // Color member, regardless if the mark has a literal value set.
                brush.Color(static_cast<til::color>(m.Color.Color));
                drawPip(m.Start.Y, false, brush);
            }

            auto searchMatches{ _core.MatchRows() };
            if (searchMatches.Size() > 0 && _searchBox->Visibility() == Visibility::Visible)
            {
                auto fgColor{ _core.ForegroundColor() };
                Media::SolidColorBrush searchMarkBrush{};
                searchMarkBrush.Color(static_cast<til::color>(fgColor));
                for (const auto m : searchMatches)
                {
                    drawPip(m, true, searchMarkBrush);
                }
            }
        }
    }

    // Method Description:
    // - Loads the search box from the xaml UI and focuses it.
    void TermControl::CreateSearchBoxControl()
    {
        // Lazy load the search box control.
        if (auto loadedSearchBox{ FindName(L"SearchBox") })
        {
            if (auto searchBox{ loadedSearchBox.try_as<::winrt::Microsoft::Terminal::Control::SearchBoxControl>() })
            {
                // get at its private implementation
                _searchBox.copy_from(winrt::get_self<implementation::SearchBoxControl>(searchBox));
                _searchBox->Visibility(Visibility::Visible);

                // If a text is selected inside terminal, use it to populate the search box.
                // If the search box already contains a value, it will be overridden.
                if (_core.HasSelection())
                {

Review comment (suggestion):
```suggestion
                const til::color fgColor{ _core.ForegroundColor() };
                Media::SolidColorBrush searchMarkBrush{};
                searchMarkBrush.Color(fgColor);
```

Code after:
            _originalPrimaryElements.Append(e);
        }
        for (const auto& e : ContextMenu().SecondaryCommands())
        {
            _originalSecondaryElements.Append(e);
        }
        for (const auto& e : SelectionContextMenu().PrimaryCommands())
        {
            _originalSelectedPrimaryElements.Append(e);
        }
        for (const auto& e : SelectionContextMenu().SecondaryCommands())
        {
            _originalSelectedSecondaryElements.Append(e);
        }
        ContextMenu().Closed([weakThis = get_weak()](auto&&, auto&&) {
            if (auto control{ weakThis.get() }; !control->_IsClosing())
            {
                const auto& menu{ control->ContextMenu() };
                menu.PrimaryCommands().Clear();
                menu.SecondaryCommands().Clear();
                for (const auto& e : control->_originalPrimaryElements)
                {
                    menu.PrimaryCommands().Append(e);
                }
                for (const auto& e : control->_originalSecondaryElements)
                {
                    menu.SecondaryCommands().Append(e);
                }
            }
        });
        SelectionContextMenu().Closed([weakThis = get_weak()](auto&&, auto&&) {
            if (auto control{ weakThis.get() }; !control->_IsClosing())
            {
                const auto& menu{ control->SelectionContextMenu() };
                menu.PrimaryCommands().Clear();
                menu.SecondaryCommands().Clear();
                for (const auto& e : control->_originalSelectedPrimaryElements)
                {
                    menu.PrimaryCommands().Append(e);
                }
                for (const auto& e : control->_originalSelectedSecondaryElements)
                {
                    menu.SecondaryCommands().Append(e);
                }
            }
        });
    }

    // Function Description:
    // - Static helper for building a new TermControl from an already existing
    //   content. We'll attach the existing swapchain to this new control's