1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-11-30 08:26:59 +02:00

Desktop: Fixes #3171: Fixed issue with accentuated letters in GotoAnything (#3183)

* fix #3171

* fix problem when searching with diacritics
This commit is contained in:
叡山电车 2020-06-02 23:57:24 +08:00 committed by GitHub
parent 2dda1c82c5
commit 3b40de1962
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,7 +9,7 @@ const Folder = require('lib/models/Folder');
const Note = require('lib/models/Note');
const { ItemList } = require('../gui/ItemList.min');
const HelpButton = require('../gui/HelpButton.min');
const { surroundKeywords, nextWhitespaceIndex } = require('lib/string-utils.js');
const { surroundKeywords, nextWhitespaceIndex, removeDiacritics } = require('lib/string-utils.js');
const { mergeOverlappingIntervals } = require('lib/ArrayUtils.js');
const PLUGIN_NAME = 'gotoAnything';
@ -234,8 +234,10 @@ class Dialog extends React.PureComponent {
const body = notesById[row.id];
// Iterate over all matches in the body for each search keyword
for (const { valueRegex } of searchKeywords) {
for (const match of body.matchAll(new RegExp(valueRegex, 'ig'))) {
for (let { valueRegex } of searchKeywords) {
valueRegex = removeDiacritics(valueRegex);
for (const match of removeDiacritics(body).matchAll(new RegExp(valueRegex, 'ig'))) {
// Populate 'indices' with [begin index, end index] of each note fragment
// Begins at the regex matching index, ends at the next whitespace after seeking 15 characters to the right
indices.push([match.index, nextWhitespaceIndex(body, match.index + match[0].length + 15)]);