Repository: microsoft/terminal
File: src/terminal/parser/stateMachine.cpp (C++)

Code before:
//      the Action*Dispatch state, and upon completion, the state's handler (eg
//      _EventCsiParam) should move us into the ground state.
// Arguments:
// - <none>
// Return Value:
// - true if the engine successfully handled the string.
bool StateMachine::FlushToTerminal()
{
    bool success{ true };

    if (success && _cachedSequence.has_value())
    {
        // Flush the partial sequence to the terminal before we flush the rest of it.
        // We always want to clear the sequence, even if we failed, so we don't accumulate bad state
        // and dump it out elsewhere later.
        success = _engine->ActionPassThroughString(*_cachedSequence);
        _cachedSequence.reset();
    }

    if (success)
    {
        // _pwchCurr is incremented after a call to ProcessCharacter to indicate
        //      that pwchCurr was processed.
        // However, if we're here, then the processing of pwchChar triggered the
        //      engine to request the entire sequence get passed through, including pwchCurr.
        _ActuateCurrentRun();
        success = _engine->ActionPassThroughString(_run);
    }

    return success;
}

// Routine Description:
// - Helper for entry to the state machine. Will take an array of characters
//     and print as many as it can without encountering a character indicating
//     a escape sequence, then feed characters into the state machine one at a
//     time until we return to the ground state.
// Arguments:
// - string - Characters to operate upon
// Return Value:
// - <none>
void StateMachine::ProcessString(const std::wstring_view string)
{
    size_t start = 0;
    size_t current = start;

    _currentString = string;
    _runOffset = 0;
    _runSize = 0;

    while (current < string.size())

Review comment (suggestion):
This can be replaced with
```cpp
success = _engine->ActionPassThroughString(_CurrentRun());
```

Code after:
//      the Action*Dispatch state, and upon completion, the state's handler (eg
//      _EventCsiParam) should move us into the ground state.
// Arguments:
// - <none>
// Return Value:
// - true if the engine successfully handled the string.
bool StateMachine::FlushToTerminal()
{
    bool success{ true };

    if (success && _cachedSequence.has_value())
    {
        // Flush the partial sequence to the terminal before we flush the rest of it.
        // We always want to clear the sequence, even if we failed, so we don't accumulate bad state
        // and dump it out elsewhere later.
        success = _engine->ActionPassThroughString(*_cachedSequence);
        _cachedSequence.reset();
    }

    if (success)
    {
        // _pwchCurr is incremented after a call to ProcessCharacter to indicate
        //      that pwchCurr was processed.
        // However, if we're here, then the processing of pwchChar triggered the
        //      engine to request the entire sequence get passed through, including pwchCurr.
        success = _engine->ActionPassThroughString(_CurrentRun());
    }

    return success;
}

// Routine Description:
// - Helper for entry to the state machine. Will take an array of characters
//     and print as many as it can without encountering a character indicating
//     a escape sequence, then feed characters into the state machine one at a
//     time until we return to the ground state.
// Arguments:
// - string - Characters to operate upon
// Return Value:
// - <none>
void StateMachine::ProcessString(const std::wstring_view string)
{
    size_t start = 0;
    size_t current = start;

    _currentString = string;
    _runOffset = 0;
    _runSize = 0;

    while (current < string.size())
    {