Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit e925dbc

Browse files
WliuWliu
Wliu
authored and
Wliu
committed
Normalize Unicode
1 parent 161ab6b commit e925dbc

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

lib/fuzzy-finder-view.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,14 @@ class FuzzyFinderView {
2323
if (colon !== -1) {
2424
query = query.slice(0, colon)
2525
}
26-
// Normalize to backslashes on Windows
27-
if (process.platform === 'win32') {
26+
27+
// Compose Unicode by default
28+
query = query.normalize('NFC')
29+
if (process.platform === 'darwin') {
30+
// But decompose on macOS
31+
query = query.normalize('NFD')
32+
} else if (process.platform === 'win32') {
33+
// Normalize to backslashes on Windows
2834
query = query.replace(/\//g, '\\')
2935
}
3036

spec/fuzzy-finder-spec.js

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -927,6 +927,42 @@ describe('FuzzyFinder', () => {
927927
})
928928
})
929929

930+
describe('unicode characters', () => {
931+
const originalPlatform = process.platform
932+
933+
afterEach(() => {
934+
Object.defineProperty(process, 'platform', {value: originalPlatform})
935+
})
936+
937+
it('decomposes unicode characters on macOS', async () => {
938+
Object.defineProperty(process, 'platform', {value: 'darwin'})
939+
940+
await bufferView.toggle()
941+
942+
bufferView.selectListView.refs.queryEditor.setText('erstiebegrüßung')
943+
944+
const query = bufferView.selectListView.getFilterQuery()
945+
expect(query.length).toBe(16)
946+
expect(query.includes('ü')).toBe(false)
947+
expect(query.includes('u\u0308')).toBe(true)
948+
})
949+
950+
it('composes unicode characters on Windows and Linux', async () => {
951+
for (let platform of ['win32, linux']) {
952+
Object.defineProperty(process, 'platform', {value: platform})
953+
954+
await bufferView.toggle()
955+
956+
bufferView.selectListView.refs.queryEditor.setText('erstiebegru\u0308ßung')
957+
958+
const query = bufferView.selectListView.getFilterQuery()
959+
expect(query.length).toBe(15)
960+
expect(query.includes('ü')).toBe(true)
961+
expect(query.includes('u\u0308')).toBe(false)
962+
}
963+
})
964+
})
965+
930966
describe('match highlighting', () => {
931967
beforeEach(async () => {
932968
jasmine.attachToDOM(workspaceElement)

0 commit comments

Comments
 (0)