SUMMARY Digraphs and trigraphs (https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C) are not handled correctly STEPS TO REPRODUCE 1. Copy the folowing code in a C++ file (from https://twitter.com/lunasorcery/status/1168256179178475520): int main() <% [](){%>(); } 2. Place the cursor after the closing brace OBSERVED RESULT The brace on the second line is highlighted The code folding "arrow" is on the third line EXPECTED RESULT The digraph on the second line is highlighted The code folding "arrow" is on the second line SOFTWARE/OS VERSIONS Linux/KDE Plasma: Operating System: Arch Linux KDE Plasma Version: 5.16.4 KDE Frameworks Version: 5.61.0 Qt Version: 5.13.0 OS Type: 64-bit
Digraphs can be easily added. The trigraphs were removed in C++17 and are almost in disuse in C, do you think it is necessary to add them also to the C highlighter? For example, at least, the folding of ??< and ??> (equivalent to { and }).
Proposed patch: https://phabricator.kde.org/D23691
Git commit 364ed572e2ec89c090c1c19dab8eab6a02518d46 by Christoph Cullmann, on behalf of Nibaldo González. Committed on 03/09/2019 at 16:46. Pushed by cullmann into branch 'master'. C & ISO C++: add digraphs (folding & preprocessor) Summary: **ISO C ++** * Add folding for digraphs `<%`, `%>`, `<:` and `:>`, which are equivalent to `{`, `}`, `[` and `]`. * Fix the highlight of `%:` in preprocessor, for example, `%:include <some>`. **C** * Add folding for digraphs `<%` and `%>`, which are equivalent to `{` and `}`. * Add `%:` equivalent to `#` in preprocessor. Trigraphs were removed in C++17 and are supported in C (if activated in the compiler), but are almost obsolete. That's why I decided not to add them. Although if you wish I can add folding to `??<` and `??>`, which are equivalent to `{` and `}`. **More:** * https://en.wikipedia.org/wiki/Digraphs_and_trigraphs#C Reviewers: #framework_syntax_highlighting, dhaumann, cullmann Reviewed By: #framework_syntax_highlighting, cullmann Subscribers: kwrite-devel, kde-frameworks-devel Tags: #kate, #frameworks Differential Revision: https://phabricator.kde.org/D23691 M +8 -0 autotests/folding/highlight.cpp.fold M +9 -0 autotests/folding/test.c.fold M +8 -0 autotests/html/highlight.cpp.html M +9 -0 autotests/html/test.c.html M +8 -0 autotests/input/highlight.cpp M +9 -0 autotests/input/test.c M +8 -0 autotests/reference/highlight.cpp.ref M +9 -0 autotests/reference/test.c.ref M +21 -16 data/syntax/c.xml M +9 -4 data/syntax/isocpp.xml https://commits.kde.org/syntax-highlighting/364ed572e2ec89c090c1c19dab8eab6a02518d46