Bug 513963 - Kate treats #ifdef blocks as comments if she evaluates them to false
Summary: Kate treats #ifdef blocks as comments if she evaluates them to false
Status: RESOLVED NOT A BUG
Alias: None
Product: kate
Classification: Applications
Component: general (other bugs)
Version First Reported In: 25.12.0
Platform: Manjaro Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-12-29 20:42 UTC by Jason
Modified: 2025-12-30 06:54 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jason 2025-12-29 20:42:41 UTC
SUMMARY

KDevelop does not do this, and I can't find anything about it, but I can't imagine why anybody would want to disable syntax highlighting within an include guard. It's been a while since I've been using KDE, but I don't remember Kate ever doing this before. I apologize if this is the desired behavior, but I can't find any documentation on it and it is undesirable behavior. I want to edit the contents of #ifdef blocks regardless of whether or not Kate thinks they will be executed.

STEPS TO REPRODUCE
Type

#ifdef __KATE__
struct test{ int m};
#endif

into a file highlighted as C++ source. 

OBSERVED RESULT

Everything in the #ifdef block is now grayed out / displayed as a comment and thus all-but unreadable. Kate does parse the file to determine whether or not she thinks the block will be evaluated, then grays out all text within the block if she thinks it will not.

EXPECTED RESULT

Syntax highlighting should be enabled in comments. I don't want or expect editors to treat or display the inside of an if() block differently based on their prediction of its behavior, so I'm under the impression this is a bug and not a desired function of the software.
SOFTWARE/OS VERSIONS
Windows: 
macOS: 
(available in the Info Center app, or by running `kinfo` in a terminal window)
Linux/KDE Plasma: 

( Manjaro Linux )
KDE Plasma Version: 6.5.4
KDE Frameworks Version: 6.21.0
Qt Version: 6.10.1

ADDITIONAL INFORMATION
Comment 1 Kåre Särs 2025-12-30 06:52:24 UTC
Sounds like you have the LSP plugin enabled and LSP can't find a definition of __KATE__ and thus marks the block as disabled.

Disabling the LSP plugin or setting up the project to work with clangd should "fix" it.

https://clangd.llvm.org/installation#project-setup

Please re-open if disabling the LSP plugin does not help.
Comment 2 Waqar Ahmed 2025-12-30 06:54:45 UTC
You can also disable "Semantic highlighting" in LSP settings.

In the future, it'd be better if we support customizing semantic highlighting colors.