From e87ecb949e77211eb21e30a97a65426f87231414 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 13 Sep 2017 10:44:49 +0200 Subject: Skip over invisible char --- components/kube/contents/ui/ComposerView.qml | 1 + framework/src/domain/documenthandler.cpp | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/components/kube/contents/ui/ComposerView.qml b/components/kube/contents/ui/ComposerView.qml index f82b4269..1571a746 100644 --- a/components/kube/contents/ui/ComposerView.qml +++ b/components/kube/contents/ui/ComposerView.qml @@ -360,6 +360,7 @@ Kube.View { onActiveFocusChanged: closeFirstSplitIfNecessary() Keys.onEscapePressed: recipients.forceActiveFocus() + cursorPosition: document.cursorPosition text: composerController.body onTextChanged: composerController.body = text; } diff --git a/framework/src/domain/documenthandler.cpp b/framework/src/domain/documenthandler.cpp index 03e5ad69..266f4a27 100644 --- a/framework/src/domain/documenthandler.cpp +++ b/framework/src/domain/documenthandler.cpp @@ -91,6 +91,21 @@ int DocumentHandler::cursorPosition() const void DocumentHandler::setCursorPosition(int position) { if (position != m_cursorPosition) { + //Skip over invisible char + if (m_cursorPosition < position) { + auto cursor = textCursor(); + cursor.movePosition(QTextCursor::NextCharacter, QTextCursor::KeepAnchor); + if (cursor.selectedText() == "\u2063") { + position++; + } + } + if (m_cursorPosition > position) { + auto cursor = textCursor(); + cursor.movePosition(QTextCursor::PreviousCharacter, QTextCursor::KeepAnchor); + if (cursor.selectedText() == "\u2063") { + position--; + } + } m_cursorPosition = position; reset(); emit cursorPositionChanged(); -- cgit v1.2.3