From 23fe87bfc9c982bbe5233bbac3da76fe0a073e8f Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Tue, 29 Mar 2022 17:22:22 +0200 Subject: [PATCH] FindAdv: Amend f78ddc49, Added handling of accented chars like \ddot{a} Only important for search without format. The format search was already OK. --- src/lyxfind.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index cda2bf0508..62be62e500 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -1092,7 +1092,11 @@ static docstring buffer_to_latex(Buffer & buffer) static string latexNamesToUtf8(docstring strIn) { string addtmp = to_utf8(strIn); - static regex const rmAcc("(\\\\)*(\\\\([A-Za-z]+)( |\\{\\})?)"); + static regex const rmAcc("(\\\\)*(" + "\\\\([A-Za-z]+\\{.\\})" // e.g. "ddot{A}" == sub.str(3) + "|\\\\([A-Za-z]+)( |\\{\\})?" // e.g. "LyX", "LyX{}", "LyX " == sub.str(5) + ")" + ); size_t lastpos = 0; smatch sub; string replace; @@ -1101,11 +1105,15 @@ static string latexNamesToUtf8(docstring strIn) buildAccentsMap(); for (sregex_iterator it_add(addtmp.begin(), addtmp.end(), rmAcc), end; it_add != end; ++it_add) { sub = *it_add; - if ((sub.position(2) - sub.position(0)) % 3 == 1) { + if ((sub.position(2) - sub.position(0)) % 2 == 1) { continue; } else { - string key = sub.str(3); + string key; + if (sub.length(3) > 0) + key = sub.str(3); + else + key = sub.str(5); AccentsIterator it_ac = accents.find(key); if (it_ac == accents.end()) { replace = sub.str(2);