diff --git a/src/widgets/DisassemblyWidget.cpp b/src/widgets/DisassemblyWidget.cpp index 76463141..153f8685 100644 --- a/src/widgets/DisassemblyWidget.cpp +++ b/src/widgets/DisassemblyWidget.cpp @@ -374,14 +374,26 @@ bool DisassemblyWidget::updateMaxLines() void DisassemblyWidget::highlightCurrentLine() { QList extraSelections; - QColor highlightColor = ConfigColor("lineHighlight"); // Highlight the current word QTextCursor cursor = mDisasTextEdit->textCursor(); - cursor.select(QTextCursor::WordUnderCursor); - QString searchString = cursor.selectedText(); - curHighlightedWord = searchString; + auto clickedCharPos = cursor.positionInBlock(); + // Select the line (BlockUnderCursor matches a line with current implementation) + cursor.select(QTextCursor::BlockUnderCursor); + // Remove any non-breakable space from the current line + QString searchString = cursor.selectedText().replace("\xc2\xa0", " "); + // Cut the line in "tokens" that can be highlighted + static const QRegularExpression tokenRegExp(R"(\b(? clickedCharPos) { + curHighlightedWord = match.captured(); + break; + } + } // Highlight the current line QTextEdit::ExtraSelection highlightSelection;