Bug 508655 - [LSP][Clangd] auto completion erases the leading space after '<' or '>' in if statement when using clangd as lsp server
Summary: [LSP][Clangd] auto completion erases the leading space after '<' or '>' in i...
Status: REPORTED
Alias: None
Product: kate
Classification: Applications
Component: part (other bugs)
Version First Reported In: 25.08.0
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-08-23 19:06 UTC by xohemay434
Modified: 2025-08-23 19:06 UTC (History)
1 user (show)

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


Attachments
screen record (33.76 KB, video/mp4)
2025-08-23 19:06 UTC, xohemay434
Details

Note You need to log in before you can comment on or make changes to this bug.
Description xohemay434 2025-08-23 19:06:04 UTC
Created attachment 184386 [details]
screen record

SUMMARY
Auto completion erases the leading space after '<' or '>'  in if statement when using clangd as lsp server.
However when I disable lsp, it works well.
Get more detail from https://discuss.kde.org/t/why-auto-completion-after-or-erases-the-leading-spaces-in-kate/38284.


STEPS TO REPRODUCE
1. launch kate and enable clangd as lsp server
2. write c++  code like:
```c++
int abcde = 1;
if (1 ) {
```

3. type '<' and a space in if statement, then type 'a' and press TAB to complete the code 

OBSERVED RESULT

the space after '<' was erased

EXPECTED RESULT

keep the space after '<'

SOFTWARE/OS VERSIONS
Kate: 25.08.0
KDE Frameworks: 6.17.0
Qt: Using 6.9.1 and built against 6.9.1
Arch Linux (Wayland)
Build ABI: x86_64-little_endian-lp64
Kernel: linux 6.12.43-1-lts


ADDITIONAL INFORMATION

When I disable lsp, it works well.

It also happens on MAC platform.



lsp configure:

```json
        "c": {
            "command": ["clangd", "-log=error", "--background-index", "--limit-results=500", "--completion-style=detailed", "--clang-tidy", "--fallback-style=\"Visual Studio\"", "--header-insertion-decorators"],
            "commandDebug": ["clangd", "-log=verbose", "--background-index"],
            "url": "https://clangd.llvm.org",
            "highlightingModeRegex": "^(C|ANSI C89|Objective-C)$"
        },
        "cpp": {
            "use": "c",
            "highlightingModeRegex": "^(C\\+\\+|ISO C\\+\\+|Objective-C\\+\\+)$"
        }
```