Hi! KSyntaxHighlighting::SyntaxHighlighter removes QTextBlock::userData() silently. I have bookmarks in my editor and they are based on QTextBlock::setUserData(). I can navigate in code and edit it without problems and without bookmark disappearance. But when I am in line where is bookmark and I edit this line then bookmark disappear. It seems that some other object appear in its place. But I can't figure out its class. This strange behaviour occurs when I switch syntax highlighting from my custom engine to KSyntaxHighlighting::SyntaxHighlighter. My old syntax highlighter does not remove bookmarks. thanks and best regards Szyk Cech
Indeed, this is because the Syntax-highlighting framework uses the userData itself to store the State and folding infos, see: https://github.com/KDE/syntax-highlighting/blob/master/src/lib/syntaxhighlighter.cpp
So: how is the recommended way to implement bookmarks? Should I dig in Kate code? Maybe someone can explain it in few words. This will save me hours...
There is one possible solution: Instead of using the ready-made QSyntaxHighlighter based solution, you could implement your own QSyntaxHighlighter-based solution. This is e.g. done in this commit in the KDE PIM suite: https://phabricator.kde.org/D7672 https://cgit.kde.org/kpimtextedit.git/commit/?id=c775ce3a438814f82cb1ba9c2c8671b9f5be08c4 Here, the class PlainTextSyntaxSpellCheckingHighlighter derives from Sonnet::Highlighter AND KSyntaxHighlighting::AbstractHighlighter. If you follow this same route, you will be able to do what you want. @Volker: I think this is the only solution to this problem, right? If so, I think we can close this bug report, correct?
Hi Szyk, after talking to Volker about this, the solution you can find in the linked sources is the only way to go if you need your own custom QTextBlocks. But give this works, there is no real bug, so we will close this as works-for-me. Kate will later use this approach as well.