Skip to content

Commit

Permalink
Prevent a crash when holding enter when creating a tab
Browse files Browse the repository at this point in the history
I guess I didn't realize that `SendCharEvent` could get called before `Create`.
In that scenario, `enter` would hit the automark codepath (due to #17761), then
crash because there was no text buffer.

Pretty easy to prevent.

Closes #17776
  • Loading branch information
zadjii-msft committed Aug 23, 2024
1 parent 6dd9c46 commit ad25998
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/cascadia/TerminalCore/Terminal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ TerminalInput::OutputType Terminal::SendCharEvent(const wchar_t ch, const WORD s
// * AND we're not in the alt buffer
//
// Then treat this line like it's a prompt mark.
if (_autoMarkPrompts)
if (_autoMarkPrompts && _mainBuffer && !_inAltBuffer())
{
// We need to be a little tricky here, to try and support folks that are
// auto-marking prompts, but don't necessarily have the rest of shell
Expand All @@ -725,10 +725,10 @@ TerminalInput::OutputType Terminal::SendCharEvent(const wchar_t ch, const WORD s
//
// (TextBuffer::_createPromptMarkIfNeeded does that work for us)

const bool createdMark = _activeBuffer().StartOutput();
const bool createdMark = _mainBuffer->StartOutput();
if (createdMark)
{
_activeBuffer().ManuallyMarkRowAsPrompt(_activeBuffer().GetCursor().GetPosition().y);
_mainBuffer->ManuallyMarkRowAsPrompt(_mainBuffer->GetCursor().GetPosition().y);

// This changed the scrollbar marks - raise a notification to update them
_NotifyScrollEvent();
Expand Down

0 comments on commit ad25998

Please sign in to comment.