fix: update longest line width

This commit is contained in:
Roy Qu 2024-03-30 11:11:34 +08:00
parent d76ef859c5
commit d31221ff42
1 changed files with 3 additions and 1 deletions

View File

@ -1212,6 +1212,8 @@ void Document::updateLongestLineWidth(int line, int width)
{
if (mIndexOfLongestLine<0) {
setIndexOfLongestLine(line);
} else if (mIndexOfLongestLine == line) {
emitMaxLineWidthChanged();
} else if (mLines[mIndexOfLongestLine]->mWidth < width) {
setIndexOfLongestLine(line);
}
@ -1822,7 +1824,7 @@ int Document::glyphWidth(const QString &glyph, int left, const QFontMetrics &fon
if (glyph.length()==0)
return 0;
QChar ch = glyph[0];
if (ch == '\t') {
if (ch == '\t') {
glyphWidth = tabWidth() - left % tabWidth();
} else {
glyphWidth = fontMetrics.horizontalAdvance(glyph);