diff --git a/lib/fuzzy-finder-view.js b/lib/fuzzy-finder-view.js index 25183fb7..3bb75571 100644 --- a/lib/fuzzy-finder-view.js +++ b/lib/fuzzy-finder-view.js @@ -23,8 +23,14 @@ class FuzzyFinderView { if (colon !== -1) { query = query.slice(0, colon) } - // Normalize to backslashes on Windows - if (process.platform === 'win32') { + + // Compose Unicode by default + query = query.normalize('NFC') + if (process.platform === 'darwin') { + // But decompose on macOS + query = query.normalize('NFD') + } else if (process.platform === 'win32') { + // Normalize to backslashes on Windows query = query.replace(/\//g, '\\') } diff --git a/spec/fuzzy-finder-spec.js b/spec/fuzzy-finder-spec.js index 9c5c21a7..2d2b295a 100644 --- a/spec/fuzzy-finder-spec.js +++ b/spec/fuzzy-finder-spec.js @@ -927,6 +927,42 @@ describe('FuzzyFinder', () => { }) }) + describe('unicode characters', () => { + const originalPlatform = process.platform + + afterEach(() => { + Object.defineProperty(process, 'platform', {value: originalPlatform}) + }) + + it('decomposes unicode characters on macOS', async () => { + Object.defineProperty(process, 'platform', {value: 'darwin'}) + + await bufferView.toggle() + + bufferView.selectListView.refs.queryEditor.setText('erstiebegrüßung') + + const query = bufferView.selectListView.getFilterQuery() + expect(query.length).toBe(16) + expect(query.includes('ü')).toBe(false) + expect(query.includes('u\u0308')).toBe(true) + }) + + it('composes unicode characters on Windows and Linux', async () => { + for (let platform of ['win32, linux']) { + Object.defineProperty(process, 'platform', {value: platform}) + + await bufferView.toggle() + + bufferView.selectListView.refs.queryEditor.setText('erstiebegru\u0308ßung') + + const query = bufferView.selectListView.getFilterQuery() + expect(query.length).toBe(15) + expect(query.includes('ü')).toBe(true) + expect(query.includes('u\u0308')).toBe(false) + } + }) + }) + describe('match highlighting', () => { beforeEach(async () => { jasmine.attachToDOM(workspaceElement)