Skip to content

Commit

Permalink
Fix crash when trying to highlight matching bracket where its line wa…
Browse files Browse the repository at this point in the history
…s hidden.
  • Loading branch information
SpartanJ committed Dec 29, 2024
1 parent 4084e38 commit a447da4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/eepp/ui/doc/documentview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,8 +341,9 @@ DocumentView::VisibleLineRange DocumentView::getVisibleLineRange( const TextPosi
}
eeASSERT( toIdx >= 0 );
info.visibleIndex = static_cast<VisibleIndex>( toIdx );
info.range = { { pos.line(), mVisibleLines[toIdx].column() },
mDoc->endOfLine( { pos.line(), 0ll } ) };
if ( info.visibleIndex != VisibleIndex::invalid )
info.range = { { pos.line(), mVisibleLines[toIdx].column() },
mDoc->endOfLine( { pos.line(), 0ll } ) };
return info;
}

Expand Down
5 changes: 5 additions & 0 deletions src/eepp/ui/uicodeeditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2234,6 +2234,8 @@ Vector2d UICodeEditor::getTextPositionOffset( const TextPosition& position,
: 0.f );
double offsetY = mDocView.getLineYOffset( info.visibleIndex, lh );
if ( isNotMonospace() ) {
if ( !info.range.isValid() )
return {};
const auto& line = mDoc->line( position.line() ).getText();
auto partialLine =
line.view().substr( info.range.start().column(), info.range.end().column() );
Expand Down Expand Up @@ -3379,6 +3381,9 @@ void UICodeEditor::drawMatchingBrackets( const Vector2f& startScroll, const Floa
primitive.setForceDraw( false );
primitive.setColor( Color( mMatchingBracketColor ).blendAlpha( mAlpha ) );
auto drawBracket = [&]( const TextPosition& pos ) {
auto info = mDocView.getVisibleLineRange( pos );
if ( !info.range.isValid() )
return;
auto offset = getTextPositionOffset( pos, lineHeight );
primitive.drawRectangle(
Rectf( Vector2f( startScroll.x + offset.x, startScroll.y + offset.y ),
Expand Down

0 comments on commit a447da4

Please sign in to comment.