fix(coding): preserve contextual unicode folding
This commit is contained in:
@@ -154,7 +154,6 @@ function foldedTextWithOffsets(value: string): {
|
||||
starts: number[];
|
||||
ends: number[];
|
||||
} {
|
||||
let text = '';
|
||||
const starts: number[] = [];
|
||||
const ends: number[] = [];
|
||||
for (let index = 0; index < value.length;) {
|
||||
@@ -163,14 +162,13 @@ function foldedTextWithOffsets(value: string): {
|
||||
const character = String.fromCodePoint(codePoint);
|
||||
const end = index + character.length;
|
||||
const folded = character.toLowerCase();
|
||||
text += folded;
|
||||
for (let foldedIndex = 0; foldedIndex < folded.length; foldedIndex += 1) {
|
||||
starts.push(index);
|
||||
ends.push(end);
|
||||
}
|
||||
index = end;
|
||||
}
|
||||
return { text, starts, ends };
|
||||
return { text: value.toLowerCase(), starts, ends };
|
||||
}
|
||||
|
||||
async function fallbackFileList(projectPath: string): Promise<string[]> {
|
||||
|
||||
@@ -110,6 +110,7 @@ describe('PI-105 project file service', () => {
|
||||
await mkdir(path.join(root, 'node_modules', 'private-package'), { recursive: true });
|
||||
await writeFile(path.join(root, 'docs', 'guide.md'), 'First line\nNeedle and needle again\n', 'utf8');
|
||||
await writeFile(path.join(root, 'docs', 'unicode.md'), 'İx needle and NEEDLE\n', 'utf8');
|
||||
await writeFile(path.join(root, 'docs', 'greek.md'), 'ΟΣ\n', 'utf8');
|
||||
await writeFile(path.join(root, 'node_modules', 'private-package', 'secret.txt'), 'needle\n', 'utf8');
|
||||
const service = new CodingProjectFileService({
|
||||
async run() {
|
||||
@@ -145,5 +146,9 @@ describe('PI-105 project file service', () => {
|
||||
{ text: 'NEEDLE', start: 14, end: 20 },
|
||||
],
|
||||
}));
|
||||
expect(await service.search(root, 'ος')).toContainEqual(expect.objectContaining({
|
||||
path: 'docs/greek.md',
|
||||
submatches: [{ text: 'ΟΣ', start: 0, end: 2 }],
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user