Repository: microsoft/terminal
File: src/cascadia/TerminalCore/Terminal.hpp (C++)

Code before:

#pragma region TextSelection
    // These methods are defined in TerminalSelection.cpp
    enum class SelectionDirection
    {
        Left,
        Right,
        Up,
        Down
    };

    enum class SelectionExpansion
    {
        Char,
        Word,
        Line, // Mouse selection only!
        Viewport,
        Buffer
    };
    void MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode);
    void SetSelectionAnchor(const COORD position);
    void SetSelectionEnd(const COORD position, std::optional<SelectionExpansion> newExpansionMode = std::nullopt);
    void SetBlockSelection(const bool isEnabled) noexcept;
    void UpdateSelection(SelectionDirection direction, SelectionExpansion mode);
    void SelectAll();
    const bool IsInQuickEditMode() const noexcept;

    using UpdateSelectionParams = std::optional<std::pair<SelectionDirection, SelectionExpansion>>;
    static UpdateSelectionParams ConvertKeyEventToUpdateSelectionParams(const ControlKeyStates mods, const WORD vkey);

    const TextBuffer::TextAndColor RetrieveSelectedTextFromBuffer(bool trimTrailingWhitespace);
#pragma endregion

private:
    std::function<void(std::wstring_view)> _pfnWriteInput;
    std::function<void()> _pfnWarningBell;
    std::function<void(std::wstring_view)> _pfnTitleChanged;
    std::function<void(std::wstring_view)> _pfnCopyToClipboard;

    // I've specifically put this instance here as it requires
    //   alignas(std::hardware_destructive_interference_size)
    // for best performance.
    //
    // But we can abuse the fact that the surrounding members rarely change and are huge
    // (std::function is like 64 bytes) to create some natural padding without wasting space.
    til::ticket_lock _readWriteLock;
#ifndef NDEBUG
    DWORD _lastLocker;
#endif

    std::function<void(const int, const int, const int)> _pfnScrollPositionChanged;

Review comment (suggestion):
There are no `const` return values. It's entirely up to the caller to decide if it's `const` or not. (There's also no `const` parameters in declarations/headers. For the same reason that's also only up to the definitions/implementations to decide whether they want it to be `const` or not).

Code after:

#pragma region TextSelection
    // These methods are defined in TerminalSelection.cpp
    enum class SelectionDirection
    {
        Left,
        Right,
        Up,
        Down
    };

    enum class SelectionExpansion
    {
        Char,
        Word,
        Line, // Mouse selection only!
        Viewport,
        Buffer
    };
    void MultiClickSelection(const COORD viewportPos, SelectionExpansion expansionMode);
    void SetSelectionAnchor(const COORD position);
    void SetSelectionEnd(const COORD position, std::optional<SelectionExpansion> newExpansionMode = std::nullopt);
    void SetBlockSelection(const bool isEnabled) noexcept;
    void UpdateSelection(SelectionDirection direction, SelectionExpansion mode);
    void SelectAll();
    bool IsInQuickEditMode() const noexcept;

    using UpdateSelectionParams = std::optional<std::pair<SelectionDirection, SelectionExpansion>>;
    static UpdateSelectionParams ConvertKeyEventToUpdateSelectionParams(const ControlKeyStates mods, const WORD vkey);

    const TextBuffer::TextAndColor RetrieveSelectedTextFromBuffer(bool trimTrailingWhitespace);
#pragma endregion

private:
    std::function<void(std::wstring_view)> _pfnWriteInput;
    std::function<void()> _pfnWarningBell;
    std::function<void(std::wstring_view)> _pfnTitleChanged;
    std::function<void(std::wstring_view)> _pfnCopyToClipboard;

    // I've specifically put this instance here as it requires
    //   alignas(std::hardware_destructive_interference_size)
    // for best performance.
    //
    // But we can abuse the fact that the surrounding members rarely change and are huge
    // (std::function is like 64 bytes) to create some natural padding without wasting space.
    til::ticket_lock _readWriteLock;
#ifndef NDEBUG
    DWORD _lastLocker;
#endif

    std::function<void(const int, const int, const int)> _pfnScrollPositionChanged;