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:
parent
453bdb293f
commit
09d088b2b5
@ -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;
|
||||
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user