codelite icon indicating copy to clipboard operation
codelite copied to clipboard

[Bug]: Auto-completion can not work on newly added files

Open zc-yoke opened this issue 4 months ago • 12 comments

What happened?

I am using CodeLite (version 18.1.0, Windows 10 64-bit) for C++ development. I noticed that when creating a new project, the automatically generated main.cpp supports code auto-completion. However, when I add existing source files to the project, these newly added files do not have auto-completion available when editing them.

Version

18.1.0

Operating system

Windows 10

Steps to reproduce


Relevant log output


zc-yoke avatar Nov 02 '25 03:11 zc-yoke

clangd requires files to be in the database, so doing a build might solve the issue.

Jarod42 avatar Nov 02 '25 09:11 Jarod42

Please read the Language Server Protocol docs, mainly focus on the clangd section.

eranif avatar Nov 02 '25 09:11 eranif

I deleted all irrelevant files and folders from the entire workspace and the project, with its complete structure shown as follows. Then, I opened the workspace again using CodeLite, and I found that the code auto-completion feature still couldn't be activated for SimpleClass.cpp and SimpleClass.h. However, files newly created via CodeLite (main.cpp, student.cpp, student.h) could still trigger the code auto-completion functionality.

C:.
│  Documents256.workspace
│ 
│  
└─Documents256
        Documents256.project
        main.cpp
        SimpleClass.cpp
        SimpleClass.h
        student.cpp
        student.h
Image Image

zc-yoke avatar Nov 02 '25 10:11 zc-yoke

I guess I'm not far from the truth. Copying text from a webpage into the source file also causes the auto-completion feature to malfunction. My code is shown below. When I delete the Chinese comments, the code completion feature works normally again.

#include "animal.h"
#include <iostream>

Animal::Animal() {
  std::cout << "Animal constructor called" << std::endl;
  std::cout << "Animal constructor" << std::endl;
}
Animal::~Animal() {
  std::cout << "Animal destructor called" << std::endl;
  const std::string name = "lucy";
}
//The following Chinese text was copied from a webpage.
//After you remove the following block comment, you can successfully trigger the code completion feature.
/**
实现了 Animal 类的构造函数和析构函数
构造函数和析构函数中简单打印了一条消息可选,用于验证调用
**/

zc-yoke avatar Nov 02 '25 12:11 zc-yoke

I am aware that UTF-8 text breaks clangd, but only seen it on Linux. For windows, it is working as it should (at least when I tried non ASCII comments in the code).

eranif avatar Nov 02 '25 12:11 eranif

Can you try the latest release? 18.2 is available and it contains many fixes, including UTF-8 fixes.

https://downloads.codelite.org/

If it does not work (or breaks something) - you can always revert back to 18.1.0: https://downloads.codelite.org/ReleaseArchive.php

eranif avatar Nov 02 '25 12:11 eranif

I downloaded version 18.2.0 and conducted tests, and I found that the issue still persists. I performed the tests using even more concise code, as shown below:

#include <iostream>
#include <string>
int main(int argc, char **argv)
{
    const std::string str="hellow world";
    std::cout<<str<<std::endl;
	return 0;
}
//一束花的仪式感,永远不会过时

zc-yoke avatar Nov 04 '25 12:11 zc-yoke

Windows 10, right?

I will use this as a base code to check if it an issue with CodeLite or clangd

eranif avatar Nov 04 '25 13:11 eranif

This seems to be working fine here. What is the code page you are using? (you can see it the bottom right in the status bar).

Image

eranif avatar Nov 04 '25 18:11 eranif

Yes (Windows 10 64-bit), I still used the same computer for the test. Please note that I found there was also a correlation with the position of this comment when I was testing. I conducted the tests with a newly created workspace and a brand-new project.

zc-yoke avatar Nov 05 '25 03:11 zc-yoke

You can also add a large block of Chinese text to the code comment section for testing to increase the probability of triggering the error. The reason I used only a few Chinese characters above is that I actually obtained them by trimming down from a large block of comments. I was trying to identify the specific character that triggered the error, but the result was not satisfactory.

你也可以将一大段中文添加到代码注释块内进行测试,以增大触发错误的概率。
之所以我上面使用了很少的几个中文字符,其实我也是从一大段注释删减得到,
我是想从中找到具体那个字符触发了错误,但结果不理想。#@!!@#@!#-?。

zc-yoke avatar Nov 05 '25 03:11 zc-yoke

Here is codepage:

Microsoft Windows [版本 10.0.19045.6456]
(c) Microsoft Corporation。保留所有权利。

C:\WINDOWS\system32>chcp
活动代码页: 936
Image

zc-yoke avatar Nov 09 '25 12:11 zc-yoke