Closed as duplicate of#1516
Closed as duplicate of#1516
Description
Make sure you have done the following
- Updated to the latest version of
blink.cmp
- Searched for existing issues and documentation (try
<C-k>
on https://cmp.saghen.dev)
Bug Description
I'm trying to use copilot with blink using blink-cmp-copilot and copilot.lua but I got segmentation fault when accepting specific completion
the file I use that consistently result segmentation fault is this one
import { Initializer, Inject, Service } from 'fastify-decorators';
import { Brackets, FindOptionsWhere, Repository } from 'typeorm';
import { PostgreSQLConnection } from '../../../data/connection/postgresql.connection';
import { BaseSQLDAO } from '../../common/common.repository';
import { EntityCategory } from '../../../data/entities/pgsql/EntityCategory.entity';
import { RequestUser } from '../../libs/types';
import { ERR_BAD_REQUEST, ERR_INTERNAL_SERVER } from '../../libs/constants/errors';
import { uuidRegex } from '../../libs/constants/regexp';
import {
// prettier-ignore
EntityCategoryMapping,
} from '../../../data/entities/pgsql/mapping/EntityCategoryMapping.entity';
import { EntityCategoryPaginationParamsDTO } from './entityCategory.dto';
import { clamp } from '../../libs/utils/helpers';
@Service()
export class EntityCategoryRepository extends BaseSQLDAO<EntityCategory> {
@Inject(PostgreSQLConnection)
protected psql: PostgreSQLConnection;
protected repository: Repository<EntityCategory>;
protected categoryMapRepository: Repository<EntityCategoryMapping>;
@Initializer([PostgreSQLConnection])
async init(): Promise<void> {
this.repository = this.psql.connection.getRepository(EntityCategory);
this.categoryMapRepository = this.psql.connection.getRepository(EntityCategoryMapping);
}
async getWithIdOrName(id: string): Promise<EntityCategory|null> {
try {
const where: FindOptionsWhere<EntityCategory>[] = [
{ name: id },
];
if (uuidRegex.test(id)) {
where.push({ id });
}
return this.repository.findOne({ where });
} catch (error) {
if (!error.code) {
throw ERR_INTERNAL_SERVER(`Get entity category with id or name error: ${error.message}`);
}
throw error;
}
}
async tagCategory(
id: string,
parentId: string,
user: RequestUser,
): Promise<EntityCategoryMapping> {
try {
const category = await this.getWithIdOrName(id);
if (!category) {
throw new ERR_BAD_REQUEST('Category not found');
}
const parentCategory = await this.getWithIdOrName(parentId);
if (!parentCategory) {
throw new ERR_BAD_REQUEST('Parent category not found');
}
const now = new Date();
const toBeEntity:Partial<EntityCategoryMapping> = {
createdBy: user.id,
createdAt: now,
updatedBy: user.id,
updatedAt: now,
categoryId: category.id,
parentCategoryId: parentCategory.id,
};
const entity = this.categoryMapRepository.create(toBeEntity);
const createdEntity = await this.categoryMapRepository.save(entity);
return createdEntity;
} catch (error) {
if (!error.code) {
throw ERR_INTERNAL_SERVER(`Tag category error: ${error.message}`);
}
throw error;
}
}
async search(
query: EntityCategoryPaginationParamsDTO,
): Promise<[EntityCategory[], number, number]> {
try {
const limit = clamp(query.$limit ?? 10, 1, 1000);
const skip = query.$page && query.$page > 1 ? (query.$page - 1) * limit : 0;
const dbQuery = this.repository.createQueryBuilder('category');
dbQuery.leftJoin('category.categories', 'parent');
if (query.name && query.name.length > 0) {
dbQuery.andWhere('category.name IN (:...name)', { name: query.name });
}
if (query.excludeId && query.excludeId.length > 0) {
dbQuery.andWhere('category.id NOT IN (:...excludeId)', { excludeId: query.excludeId });
}
if (query.excludeName && query.excludeName.length > 0) {
dbQuery.andWhere(
'category.name NOT IN (:...excludeName)',
{ excludeName: query.excludeName },
);
}
if (query.parentId && query.parentId.length > 0) {
dbQuery.andWhere('parent.id IN (:...parentId)', { parentId: query.parentId });
}
if (query.parentName && query.parentName.length > 0) {
dbQuery.andWhere('parent.name IN (:...parentName)', { parentName: query.parentName });
}
if (query.excludeParentId && query.excludeParentId.length > 0) {
const tagQuery = this.categoryMapRepository.createQueryBuilder('tag');
tagQuery.select('tag.categoryId');
tagQuery.where(
'tag.parentCategoryId IN (:...excludeParentId)',
{ excludeParentId: query.excludeParentId },
);
const [tagQueryString, queryParams] = tagQuery.getQueryAndParameters();
dbQuery.andWhere(`category.id NOT IN (${tagQueryString})`, queryParams);
}
if (query.excludeParentOfId && ) {
}
if (query.search) {
const { searchKey = ['name', 'label', 'description'] } = query;
dbQuery.andWhere(
new Brackets((qb) => {
searchKey.forEach((key) => {
qb.orWhere(`category.${key} ILIKE :search`, { search: `%${query.search}%` });
});
}),
);
}
if (query.$order) {
const orderKeyList = query.$order.split(',');
const sortList = query.$sort ? query.$sort.split(',') : [];
orderKeyList.forEach((key, index) => {
dbQuery.addOrderBy(key, <'ASC' | 'DESC'>sortList[index] || 'ASC');
});
} else {
dbQuery.orderBy('category.name', 'ASC');
}
dbQuery.skip(skip);
dbQuery.take(limit);
const [data, count] = await dbQuery.getManyAndCount();
return [data, count, Math.ceil(count / limit)];
} catch (error) {
if (!error.code) {
throw ERR_INTERNAL_SERVER(`Search entity category error: ${error.message}`);
}
throw error;
}
}
}
When I select copilot completion at this line it would cause segmentation fault
When I select copilot completion at this line instead it doesn't cause segmentation fault
Relevant configuration
return {
'saghen/blink.cmp',
dependencies = {
'rafamadriz/friendly-snippets',
{
dependencies = {
{
"zbirenbaum/copilot.lua",
cmd = "Copilot",
build = ":Copilot auth",
event = "InsertEnter",
opts = {
suggestion = { enabled = false },
panel = { enabled = false },
},
},
},
"giuxtaposition/blink-cmp-copilot",
},
},
opts = {
sources = {
default = {
'lsp',
'path',
'snippets',
'buffer',
'copilot',
},
providers = {
copilot = {
name = "copilot",
module = "blink-cmp-copilot",
score_offset = 100,
async = true,
},
},
},
},
}
neovim
version
0.10.2
blink.cmp
version
1.3.1