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

Code before:
    }

    // Method Description:
    // * Same as ShouldShowSelectCommand, but with the mark needing output
    bool ControlCore::ShouldShowSelectOutput()
    {
        // Relies on the anchor set in AnchorContextMenu

        // Don't show this if the click was on the selection
        if (_terminal->IsSelectionActive() &&
            _terminal->GetSelectionAnchor() <= _contextMenuBufferPosition &&
            _terminal->GetSelectionEnd() >= _contextMenuBufferPosition)
        {
            return false;
        }

        // DO show this if the click was on a mark with output
        const auto& marks{ _terminal->GetScrollMarks() };
        for (auto&& m : marks)
        {
            if (!m.HasOutput())
            {
                continue;
            }
            const auto [start, end] = m.GetExtent();
            if (start <= _contextMenuBufferPosition &&
                end >= _contextMenuBufferPosition)
            {
                return true;
            }
        }
        // Didn't click on a mark with output - don't show.
        return false;
    }
}


Review comment (suggestion):
```suggestion
        for (const auto&& m : marks)
```

Code after:
            [](const DispatchTypes::ScrollMark& m) -> bool { return !m.HasCommand(); },
            [](const DispatchTypes::ScrollMark& m) { return til::point_span{ m.end, *m.commandEnd }; });
    }
    void ControlCore::ContextMenuSelectOutput()
    {
        _contextMenuSelectMark(
            _contextMenuBufferPosition,
            [](const DispatchTypes::ScrollMark& m) -> bool { return !m.HasOutput(); },
            [](const DispatchTypes::ScrollMark& m) { return til::point_span{ *m.commandEnd, *m.outputEnd }; });
    }

    bool ControlCore::_clickedOnMark(
        const til::point& pos,
        const std::function<bool(const DispatchTypes::ScrollMark&)>& filter)
    {
        // Don't show this if the click was on the selection
        if (_terminal->IsSelectionActive() &&
            _terminal->GetSelectionAnchor() <= pos &&
            _terminal->GetSelectionEnd() >= pos)
        {
            return false;
        }

        // DO show this if the click was on a mark with a command
        const auto& marks{ _terminal->GetScrollMarks() };
        for (auto&& m : marks)
        {
            if (filter && filter(m))
            {
                continue;
            }
            const auto [start, end] = m.GetExtent();
            if (start <= pos &&
                end >= pos)
            {
                return true;
            }
        }

        // Didn't click on a mark with a command - don't show.
        return false;
    }

    // Method Description:
    // * Don't show this if the click was on the _current_ selection
    // * Don't show this if the click wasn't on a mark with at least a command
    // * Otherwise yea, show it.
    bool ControlCore::ShouldShowSelectCommand()
    {
        // Relies on the anchor set in AnchorContextMenu
        return _clickedOnMark(_contextMenuBufferPosition,