Skip to content

Commit

Permalink
fix: double click edit incorrect format
Browse files Browse the repository at this point in the history
  • Loading branch information
kegechen committed Jan 9, 2024
1 parent 4194393 commit b420d5a
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/widgets/dcrumbedit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,6 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate

void registerHandler(QAbstractTextDocumentLayout *layout)
{
D_Q(DCrumbEdit);

for (int i = QTextFormat::UserObject + 1; ; ++i) {
if (!layout->handlerForObject(i)) {
objectType = i;
Expand Down Expand Up @@ -379,7 +377,9 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate
if (cursor.charFormat().objectType() != objectType)
return false;

DCrumbTextFormat format(cursor.charFormat());
auto fmt = q->document()->documentLayout()->formatAt(mousePos);
DCrumbTextFormat format = formats.value(fmt.stringProperty(QTextFormat::UserProperty + 1));

currentText = format.text();
currentBrush = format.background();

Expand All @@ -391,7 +391,8 @@ class DCrumbEditPrivate : public DCORE_NAMESPACE::DObjectPrivate

makeCrumb();

if (mousePos.x() < q->cursorRect().left())
if (mousePos.x() < q->cursorRect().left() ||
mousePos.y() < q->cursorRect().top())
cursor.setPosition(cursor.position() - 1, QTextCursor::KeepAnchor);
else
cursor.setPosition(cursor.position() + 1, QTextCursor::KeepAnchor);
Expand Down

0 comments on commit b420d5a

Please sign in to comment.