From 115d6ceeddf90a71fcb0556411b3c68aae63ddad Mon Sep 17 00:00:00 2001 From: Kornel Benko Date: Sat, 14 May 2022 08:56:00 +0200 Subject: [PATCH] FindAdv: Don't check on '\\\\\n' if ignoring format Since it can only happen if the lyx source contains two backslasches before the inserted newline. And here it is the wrong case. --- src/lyxfind.cpp | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 40d20c40da..4f5d97df75 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -4000,31 +4000,29 @@ static string convertLF2Space(docstring const &s, bool ignore_format) t << lyx::to_utf8(s.substr(start, end + 1 - start)); break; } - if ((pos > start+2) && - s[pos-1] == '\\' && - s[pos-2] == '\\') { - if (s[pos-1] == '\\' && s[pos-2] == '\\') { + if (!ignore_format) { + if ((pos > start + 1) && + s[pos-1] == '\\' && + s[pos-2] == '\\') { skip = 2; - if ((pos > start+3) && + if ((pos > start + 2) && (s[pos+1] == '~' || isSpace(s[pos+1]) || s[pos-3] == '~' || isSpace(s[pos-3]))) { // discard '\n' dospace = false; } } - else if (s[pos-1] == '\\' && s[pos-2] == '\\') - skip = 2; - } - else if (!ignore_format && (pos > start) && - s[pos-1] == '%') { - skip = 1; - while ((pos > start+skip) && (s[pos-1-skip] == '%')) - skip++; - if ((pos > start+skip) && - (s[pos+1] == '~' || isSpace(s[pos+1]) || - s[pos-1-skip] == '~' || isSpace(s[pos-1-skip]))) { - // discard '%%%%%\n' - dospace = false; + else if ((pos > start) && + s[pos-1] == '%') { + skip = 1; + while ((pos > start+skip) && (s[pos-1-skip] == '%')) + skip++; + if ((pos > start+skip) && + (s[pos+1] == '~' || isSpace(s[pos+1]) || + s[pos-1-skip] == '~' || isSpace(s[pos-1-skip]))) { + // discard '%%%%%\n' + dospace = false; + } } } else {