Displaying Problems inline in KDevelop
In 2018 the KTextEditor framework which powers the editor of
KDevelop gained support for
displaying inline notes enabling to show
information inside the editor without interfering with the editing process. One of the prototypes shown during the development
of the interface for displaying such notes was showing detetcted problems like compiler warnings and errors in the affected line. Being a KDevelop user for quite some time now I was excited about that
feature when I read the blog post linked earlier. Unfortunately, it didn’t get implemented straight away and I forgot about
it - until recently when the inline note cababilities were brought up on IRC. I though to myself: “How hard can it be?”
And thanks to the incredible work done when implementing the InlineNote
and related interfaces into KTextEditor and the
extensible structure of KDevelop it wasn’t hard at all! The work needing to be done was basically plugging the two systems
together and deciding how the notes should look like.
The feature as implemented will show a short description of a detected problem next to the line that contains it in a color and with a fitting icon depending on the severity of the problem. I think this is a huge productivity booster because you can see what’s wrong at a glance without the need to do anything and can fix it right away. If you want a more detailed explanation of the problem, you can hover over the location of the problem marked by the curly underline as before or over the inline note. By default inline notes will be shown in lines that contain warnings and erorrs, but you can change it so they’re visible for hints too or only for errors. Of course, if you are not as excited as me you about such a feature, you can also disable them entirely.
Lastly, huge thanks to everyone who made this possible to implement. A special shoutout to Friedrich W. H. Kossebau
who helped finalizing the actual look of the notes!
The patch is now merged to the master branch and if you want to try it you can grab the source code on
the Gitlab instance of KDE and can find
compile instructions on the community wiki. Have fun testing!