From c32235ffe35fbed357426fb4e5ddc9ff72ffdbe6 Mon Sep 17 00:00:00 2001 From: James Graham Date: Thu, 5 Feb 2026 19:59:32 +0000 Subject: [PATCH] Improve application of text formats from buttons. - If the bar is empty they are now applied as normal - If there is a selection or the cursor is next to a word it is applied to it. - If there is no selected text and no word it is applied properly to the next char --- src/libneochat/chattextitemhelper.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/libneochat/chattextitemhelper.cpp b/src/libneochat/chattextitemhelper.cpp index 4c80f901c..d8e3d61f3 100644 --- a/src/libneochat/chattextitemhelper.cpp +++ b/src/libneochat/chattextitemhelper.cpp @@ -481,7 +481,15 @@ void ChatTextItemHelper::mergeTextFormatOnCursor(RichFormat::Format format, QTex if (!cursor.hasSelection()) { cursor.select(QTextCursor::WordUnderCursor); } - cursor.mergeCharFormat(charFormat); + + if (!cursor.hasSelection() && isEmpty()) { + cursor.mergeBlockCharFormat(charFormat); + } else if (!cursor.hasSelection()) { + cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); + cursor.mergeCharFormat(charFormat); + } else { + cursor.mergeCharFormat(charFormat); + } Q_EMIT charFormatChanged(); }