Repository: microsoft/terminal
File: src/buffer/out/search.h (C/C++)

Code before:
#include "../renderer/inc/IRenderData.hpp"

// This used to be in find.h.
#define SEARCH_STRING_LENGTH (80)

class Search final
{
public:
    enum class Direction
    {
        Forward,
        Backward
    };

    enum class Sensitivity
    {
        CaseInsensitive,
        CaseSensitive
    };

    Search(Microsoft::Console::Render::IRenderData& uiaData,
           const std::wstring_view str,
           const Direction dir,
           const Sensitivity sensitivity);

    Search(Microsoft::Console::Render::IRenderData& uiaData,
           const std::wstring_view str,
           const Direction dir,
           const Sensitivity sensitivity,
           const til::point anchor);

    bool FindNext();
    void Select() const;
    void Color(const TextAttribute attr) const;

    std::pair<til::point, til::point> GetFoundLocation() const noexcept;

private:
    wchar_t _ApplySensitivity(const wchar_t wch) const noexcept;
    bool _FindNeedleInHaystackAt(const til::point pos, til::point& start, til::point& end) const;
    bool _CompareChars(const std::wstring_view one, const std::wstring_view two) const noexcept;
    void _UpdateNextPosition();

    void _IncrementCoord(til::point& coord) const noexcept;
    void _DecrementCoord(til::point& coord) const noexcept;

    static til::point s_GetInitialAnchor(const Microsoft::Console::Render::IRenderData& uiaData, const Direction dir);

    static std::vector<std::vector<wchar_t>> s_CreateNeedleFromString(const std::wstring_view wstr);

    bool _reachedEnd = false;

Review comment (suggestion):
```suggestion
    Search(Microsoft::Console::Render::IRenderData& renderData,
```

Code after:
#include "../renderer/inc/IRenderData.hpp"

// This used to be in find.h.
#define SEARCH_STRING_LENGTH (80)

class Search final
{
public:
    enum class Direction
    {
        Forward,
        Backward
    };

    enum class Sensitivity
    {
        CaseInsensitive,
        CaseSensitive
    };

    Search(Microsoft::Console::Render::IRenderData& renderData,
           const std::wstring_view str,
           const Direction dir,
           const Sensitivity sensitivity);

    Search(Microsoft::Console::Render::IRenderData& renderData,
           const std::wstring_view str,
           const Direction dir,
           const Sensitivity sensitivity,
           const til::point anchor);

    bool FindNext();
    void Select() const;
    void Color(const TextAttribute attr) const;

    std::pair<til::point, til::point> GetFoundLocation() const noexcept;

private:
    wchar_t _ApplySensitivity(const wchar_t wch) const noexcept;
    bool _FindNeedleInHaystackAt(const til::point pos, til::point& start, til::point& end) const;
    bool _CompareChars(const std::wstring_view one, const std::wstring_view two) const noexcept;
    void _UpdateNextPosition();

    void _IncrementCoord(til::point& coord) const noexcept;
    void _DecrementCoord(til::point& coord) const noexcept;

    static til::point s_GetInitialAnchor(const Microsoft::Console::Render::IRenderData& renderData, const Direction dir);

    static std::vector<std::wstring> s_CreateNeedleFromString(const std::wstring_view wstr);

    bool _reachedEnd = false;