diff --git a/Editor.cpp b/Editor.cpp index 0809cf2..26ff5bd 100644 --- a/Editor.cpp +++ b/Editor.cpp @@ -334,7 +334,7 @@ struct DefaultEditorVisitor: MultipleVisitorcode()->str()); + auto rect = textRect(code); fillRect(QRect(0, y, m_maxWidth, rect.height()), QBrush(QColor(249, 249, 249))); - drawText(rect, node->code()->str()); + drawText(rect, code); restore(); m_curY += rect.height(); m_curY += 10; } + void visit(CodeBlock *node) override { + if (node && node->code()) { + auto code = node->code()->str(); + drawCodeBlock(code); + } + } void visit(InlineCode *node) override { save(); // #f9f9f9 @@ -362,10 +368,15 @@ struct DefaultEditorVisitor: MultipleVisitorcode() ? node->code()->str() : " "; - auto rect = textRect(code); - fillRect(rect, QBrush(QColor(249, 249, 249))); - drawText(rect, code); - m_curX += rect.width(); + if (currentLineCanDrawText(code)) { + auto rect = textRect(code); + fillRect(rect, QBrush(QColor(249, 249, 249))); + drawText(rect, code); + m_curX += rect.width(); + m_lastMaxHeight = qMax(m_lastMaxHeight, rect.height()); + } else { + drawCodeBlock(code); + } restore(); } void visit(LatexBlock *node) override {