1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-24 10:27:10 +02:00

Mobile,Desktop: Fix nonbreaking spaces and CRLF break search for adjacent words (#10417)

This commit is contained in:
Henry Heino 2024-05-12 02:01:12 -07:00 committed by GitHub
parent 453bdb293f
commit 09d088b2b5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 0 deletions

View File

@ -340,6 +340,20 @@ describe('services/SearchEngine', () => {
expect((await engine.search('testing')).length).toBe(1);
}));
it('should use nonbreaking spaces as separators', (async () => {
await Note.save({
title: 'Test',
body: 'This is\u00A0a\u00A0test\r\nof different\r\nspace separators.',
});
await engine.syncTables();
expect((await engine.search('test')).length).toBe(1);
expect((await engine.search('different')).length).toBe(1);
expect((await engine.search('space')).length).toBe(1);
expect((await engine.search('separators')).length).toBe(1);
}));
it('should supports various query types', (async () => {
let rows;

View File

@ -629,6 +629,10 @@ export default class SearchEngine {
// https://github.com/laurent22/joplin/issues/9694
normalizedText = htmlentitiesDecode(normalizedText);
// The FTS tokenizer doesn't understand some types of space,
// including nonbreaking spaces and CRLF.
normalizedText = normalizedText.replace(/\s/g, ' ');
return removeDiacritics(normalizedText.toLowerCase());
}