Repository: microsoft/terminal
File: src/cascadia/TerminalCore/TerminalApi.cpp (C++)

Code before:

        // Move the end of this mark to the current cursor position. The prompt
        // is between [mark.start, mark.end)
        _currentPrompt->end = cursorPos;
    }
}

void Terminal::OutputStart()
{
    if (_currentPrompt)
    {
        const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };
        // Mark the current cursor pos as the the end of the command. The command
        // is between [mark.end, mark.commandEnd)
        _currentPrompt->commandEnd = cursorPos;
    }
}

void Terminal::CommandFinished(std::optional<unsigned int> error)
{
    if (_currentPrompt)
    {
        const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };
        // Mark the current cursor pos as the the end of the output. The command
        // is between [mark.commandEnd, mark.outputEnd)
        _currentPrompt->outputEnd = cursorPos;

        if (error.has_value())
        {
            _currentPrompt->category = *error == 0u ?
                                           DispatchTypes::MarkCategory::Success :
                                           DispatchTypes::MarkCategory::Error;
        }
    }
}

// Method Description:
// - Reacts to a client asking us to show or hide the window.
// Arguments:
// - showOrHide - True for show. False for hide.
// Return Value:
// - <none>
void Terminal::ShowWindow(bool showOrHide)
{
    if (_pfnShowWindowChanged)
    {
        _pfnShowWindowChanged(showOrHide);
    }
}

bool Terminal::IsConsolePty() const

Review comment (suggestion):
```suggestion
        // Mark the current cursor pos as the the end of the output. The command
        // is between [mark.commandEnd, mark.outputEnd)
        _currentPrompt->outputEnd = _activeBuffer().GetCursor().GetPosition();
```
if you want

Code after:
    _updateUrlDetection();

    // GH#3321: Make sure we let the TerminalInput know that we switched
    // buffers. This might affect how we interpret certain mouse events.
    _terminalInput->UseMainScreenBuffer();

    // Update scrollbars
    _NotifyScrollEvent();

    // redraw the screen
    try
    {
        _activeBuffer().TriggerRedrawAll();
    }
    CATCH_LOG();
}

// NOTE: This is the version of AddMark that comes from VT
void Terminal::MarkPrompt(const DispatchTypes::ScrollMark& mark)
{
    static bool logged = false;
    if (!logged)
    {
        TraceLoggingWrite(
            g_hCTerminalCoreProvider,
            "ShellIntegrationMarkAdded",
            TraceLoggingDescription("A mark was added via VT at least once"),
            TraceLoggingKeyword(MICROSOFT_KEYWORD_MEASURES),
            TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));

        logged = true;
    }

    const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };
    AddMark(mark, cursorPos, cursorPos, false);

    if (mark.category == DispatchTypes::MarkCategory::Prompt)
    {
        _currentPromptState = PromptState::Prompt;
    }
}

void Terminal::MarkCommandStart()
{
    const til::point cursorPos{ _activeBuffer().GetCursor().GetPosition() };

    if ((_currentPromptState == PromptState::Prompt) &&
        (_scrollMarks.size() > 0))
    {
        // We were in the right state, and there's a previous mark to work
        // with.