From f0f79c2917e8f143a9ead8e0c3d10505e258d154 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Fri, 1 Mar 2024 20:10:18 +0800 Subject: [PATCH] Wrong indent line position for non-monospace fonts. --- libs/qsynedit/qsynedit/document.h | 8 +++++++- libs/qsynedit/qsynedit/painter.cpp | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/libs/qsynedit/qsynedit/document.h b/libs/qsynedit/qsynedit/document.h index 282ff445..ec66b126 100644 --- a/libs/qsynedit/qsynedit/document.h +++ b/libs/qsynedit/qsynedit/document.h @@ -540,7 +540,13 @@ public: } int tabWidth() const { - return mTabSize * mSpaceWidth; + return mTabSize * spaceWidth(); + } + + int spaceWidth() const { + if (mForceMonospace) + return mCharWidth; + return mSpaceWidth; } void setTabSize(int newTabSize); diff --git a/libs/qsynedit/qsynedit/painter.cpp b/libs/qsynedit/qsynedit/painter.cpp index 5e5953cc..67d36899 100644 --- a/libs/qsynedit/qsynedit/painter.cpp +++ b/libs/qsynedit/qsynedit/painter.cpp @@ -761,7 +761,7 @@ void QSynEditPainter::paintFoldAttributes() tabSteps = 0; indentLevel = 0; while (tabSteps < lineIndent) { - X = tabSteps * mEdit->mCharWidth + mEdit->textOffset() - 1; + X = tabSteps * mEdit->mDocument->spaceWidth() + mEdit->textOffset() - 1; tabSteps+=mEdit->tabSize(); indentLevel++ ; if (mEdit->mSyntaxer) {