TexRow texrow;
odocstringstream ods;
+ otexstream os(ods);
OutputParams runparams(&buf.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
pos_type endpos = cur.paragraph().size();
if (len != -1 && endpos > cur.pos() + len)
endpos = cur.pos() + len;
- TeXOnePar(buf, *cur.innerText(), cur.pit(), ods, texrow, runparams,
+ TeXOnePar(buf, *cur.innerText(), cur.pit(), os, texrow, runparams,
string(), cur.pos(), endpos);
LYXERR(Debug::FIND, "Latexified text: '" << lyx::to_utf8(ods.str()) << "'");
} else if (cur.inMathed()) {
docstring stringifyFromForSearch(FindAndReplaceOptions const & opt,
DocIterator const & cur, int len)
{
+ LASSERT(cur.pos() >= 0 && cur.pos() <= cur.lastpos(), /* */);
if (!opt.ignoreformat)
return latexifyFromCursor(cur, len);
else
repl_buffer.params().documentClassPtr(),
bv->buffer().errorList("Paste"));
LYXERR(Debug::FIND, "After pasteParagraphList() cur=" << cur << endl);
+ sel_len = repl_buffer.paragraphs().begin()->size();
} else {
odocstringstream ods;
+ otexstream os(ods);
OutputParams runparams(&repl_buffer.params().encoding());
runparams.nice = false;
runparams.flavor = OutputParams::LATEX;
runparams.linelen = 8000; //lyxrc.plaintext_linelen;
runparams.dryrun = true;
TexRow texrow;
- TeXOnePar(repl_buffer, repl_buffer.text(), 0, ods, texrow, runparams);
+ TeXOnePar(repl_buffer, repl_buffer.text(), 0, os, texrow, runparams);
//repl_buffer.getSourceCode(ods, 0, repl_buffer.paragraphs().size(), false);
docstring repl_latex = ods.str();
LYXERR(Debug::FIND, "Latexified replace_buffer: '" << repl_latex << "'");
regex_replace(s, s, "\\\\\\[(.*)\\\\\\]", "$1");
repl_latex = from_utf8(s);
LYXERR(Debug::FIND, "Replacing by niceInsert()ing latex: '" << repl_latex << "'");
- cur.niceInsert(repl_latex);
+ sel_len = cur.niceInsert(repl_latex);
}
- cur.pos() -= repl_buffer.paragraphs().begin()->size();
- LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << repl_buffer.paragraphs().begin()->size());
- bv->putSelectionAt(DocIterator(cur), repl_buffer.paragraphs().begin()->size(), !opt.forward);
+ cur.pos() -= sel_len;
+ if (cur.pos() < 0)
+ cur.pos() = 0;
+ LYXERR(Debug::FIND, "Putting selection at cur=" << cur << " with len: " << sel_len);
+ bv->putSelectionAt(DocIterator(cur), sel_len, !opt.forward);
bv->processUpdateFlags(Update::Force);
}