From f1965e9ff1485f58139aad2f3057a181709279b7 Mon Sep 17 00:00:00 2001 From: Tommaso Cucinotta Date: Thu, 26 May 2011 17:08:48 +0000 Subject: [PATCH] Bugfix in how the search buffer was exported for the Advanced Find & Replace. For example, before this footnotes were not correctly found. Added also accompanying regression test. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38846 a592a061-630c-0410-9148-cb99ea01b6c8 --- development/autotests/findadv-13-in.txt | 15 +++++++++++++++ src/lyxfind.cpp | 14 ++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 development/autotests/findadv-13-in.txt diff --git a/development/autotests/findadv-13-in.txt b/development/autotests/findadv-13-in.txt new file mode 100644 index 0000000000..701d23cac1 --- /dev/null +++ b/development/autotests/findadv-13-in.txt @@ -0,0 +1,15 @@ +# Finding footnotes +# +Lang it_IT.utf8 +TestBegin test.lyx -dbg find > lyx-log.txt 2>&1 +KK: \Axfootnote-insert\[Return] +# Work around a little UI bug/non-determinism in cursor position after LFUN +KK: \C\[Home]\[Right] +KK: foo\C\[Home] +KK: \CF +KK: \Axfootnote-insert\[Return] +# Work around a little UI bug/non-determinism in cursor position after LFUN +KK: \C\[Home]\[Right] +KK: foo\[Return] +TestEnd +Assert pcregrep -M 'Putting selection at .*idx: 0 par: 0 pos: 0\n with len: 1' lyx-log.txt diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index 62b0b1c29a..1aa228b4a5 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -743,21 +743,19 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co if (!opt.ignoreformat) { str = buffer_to_latex(buffer); } else { - ParIterator it = buffer.par_iterator_begin(); - ParIterator end = buffer.par_iterator_end(); OutputParams runparams(&buffer.params().encoding()); - odocstringstream os; runparams.nice = true; runparams.flavor = OutputParams::LATEX; runparams.linelen = 100000; //lyxrc.plaintext_linelen; runparams.dryrun = true; - for (; it != end; ++it) { + for (pos_type pit = pos_type(0); pit < (pos_type)buffer.paragraphs().size(); ++pit) { + Paragraph const & par = buffer.paragraphs().at(pit); LYXERR(Debug::FIND, "Adding to search string: '" - << it->asString(false) + << par.stringify(pos_type(0), par.size(), + AS_STR_INSETS, runparams) << "'"); - str += - it->stringify(pos_type(0), it->size(), - AS_STR_INSETS, runparams); + str += par.stringify(pos_type(0), par.size(), + AS_STR_INSETS, runparams); } } return str;