Am Fri, 22 Jan 2021 11:02:05 -0500 schrieb Richard Kimberly Heck <rikih...@lyx.org>:
> On 1/22/21 10:26 AM, Jürgen Spitzmüller wrote: > > Am Freitag, dem 22.01.2021 um 14:04 +0100 schrieb Kornel Benko: > >> As the subject says. > >> > >> ATM it is the case, but I'd like to change it. > >> (see output_latex.cpp:447,762,1668,1677) > > I think deleted material should be ignored, as in simple search > > (nowadays). > > How hard is it to add a checkbox to allow both? I can well imagine both > would be useful. > > Riki > > FWIW, here the patch to search in deleted text. (I too think, a checkbox would be nice.) Kornel
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp index d5bfb76320..38fe2a7b35 100644 --- a/src/Paragraph.cpp +++ b/src/Paragraph.cpp @@ -2515,10 +2515,11 @@ void Paragraph::latex(BufferParams const & bparams, ? runparams.changeOfDeletedInset : lookupChange(i); char_type const c = d->text_[i]; // Check whether a display math inset follows + bool output_changes = bparams.output_changes || runparams.for_search; if (c == META_INSET && i >= start_pos && (end_pos == -1 || i < end_pos)) { if (isDeleted(i)) runparams.ctObject = getInset(i)->getCtObject(runparams); @@ -2530,11 +2531,11 @@ void Paragraph::latex(BufferParams const & bparams, // latexInset later, but we need this info // before it is called. On the other hand, we // cannot set it here because it is a counter. deleted_display_math = isDeleted(i); } - if (bparams.output_changes && deleted_display_math + if (output_changes && deleted_display_math && runningChange == change && change.type == Change::DELETED && !os.afterParbreak()) { // A display math in the same paragraph follows. // We have to close and then reopen \lyxdeleted, @@ -2553,11 +2554,11 @@ void Paragraph::latex(BufferParams const & bparams, column += Changes::latexMarkChange(os, bparams, Change(Change::INSERTED), change, rp); } } - if (bparams.output_changes && runningChange != change) { + if (output_changes && runningChange != change) { if (!alien_script.empty()) { column += 1; os << "}"; alien_script.clear(); } @@ -2576,11 +2577,11 @@ void Paragraph::latex(BufferParams const & bparams, runningChange = change; } // do not output text which is marked deleted // if change tracking output is disabled - if (!bparams.output_changes && change.deleted()) { + if (!output_changes && change.deleted()) { continue; } ++column; @@ -2590,11 +2591,11 @@ void Paragraph::latex(BufferParams const & bparams, Font const prev_font = (i > 0) ? getFont(bparams, i - 1, outerfont) : current_font; Font const last_font = running_font; - bool const in_ct_deletion = (bparams.output_changes + bool const in_ct_deletion = (output_changes && runningChange == change && change.type == Change::DELETED && !os.afterParbreak()); // Insets where font switches are used (rather than font commands) bool const fontswitch_inset = diff --git a/src/lyxfind.cpp b/src/lyxfind.cpp index be529ca19a..463faa2998 100644 --- a/src/lyxfind.cpp +++ b/src/lyxfind.cpp @@ -922,15 +922,15 @@ static docstring stringifySearchBuffer(Buffer & buffer, FindAndReplaceOptions co runparams.for_search = true; 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: '" << par.asString(pos_type(0), par.size(), - AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT, + AS_STR_INSETS | AS_STR_PLAINTEXT, &runparams) << "'"); str += par.asString(pos_type(0), par.size(), - AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT, + AS_STR_INSETS | AS_STR_PLAINTEXT, &runparams); } // Even in ignore-format we have to remove "\text{}, \lyxmathsym{}" parts string t = to_utf8(str); while (regex_replace(t, t, "\\\\(text|lyxmathsym)\\{([^\\}]*)\\}", "$2")); @@ -3312,11 +3312,11 @@ docstring stringifyFromCursor(DocIterator const & cur, int len) runparams.dryrun = true; runparams.for_search = true; LYXERR(Debug::FIND, "Stringifying with cur: " << cur << ", from pos: " << cur.pos() << ", end: " << end); return par.asString(cur.pos(), end, - AS_STR_INSETS | AS_STR_SKIPDELETE | AS_STR_PLAINTEXT, + AS_STR_INSETS | AS_STR_PLAINTEXT, &runparams); } else if (cur.inMathed()) { CursorSlice cs = cur.top(); MathData md = cs.cell(); MathData::const_iterator it_end = diff --git a/src/output_latex.cpp b/src/output_latex.cpp index 2f5d964a47..fe50442064 100644 --- a/src/output_latex.cpp +++ b/src/output_latex.cpp @@ -442,11 +442,11 @@ void TeXEnvironment(Buffer const & buf, Text const & text, ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1); Paragraph const & cpar = paragraphs.at(pit); if ((par->layout() != nextpar->layout() || par->params().depth() == nextpar->params().depth() || par->params().leftIndent() == nextpar->params().leftIndent()) - && !cpar.empty() + && !runparams.for_search && !cpar.empty() && cpar.isDeleted(0, cpar.size()) && !buf.params().output_changes) { if (!buf.params().output_changes && !cpar.parEndChange().deleted()) os << '\n' << '\n'; continue; } @@ -757,11 +757,11 @@ void TeXOnePar(Buffer const & buf, if (style.inpreamble && !force) return; // Do not output empty commands if the whole paragraph has // been deleted with ct and changes are not output. - if (style.latextype != LATEX_ENVIRONMENT + if (!runparams_in.for_search && style.latextype != LATEX_ENVIRONMENT && !par.empty() && par.isDeleted(0, par.size()) && !bparams.output_changes) return; LYXERR(Debug::LATEX, "TeXOnePar for paragraph " << pit << " ptr " << &par << " '" << everypar << "'"); @@ -1663,20 +1663,20 @@ void latexParagraphs(Buffer const & buf, ParagraphList::const_iterator nextpar = paragraphs.iterator_at(pit + 1); Paragraph const & cpar = paragraphs.at(pit); if ((par->layout() != nextpar->layout() || par->params().depth() == nextpar->params().depth() || par->params().leftIndent() == nextpar->params().leftIndent()) - && !cpar.empty() + && !runparams.for_search && !cpar.empty() && cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) { if (!cpar.parEndChange().deleted()) os << '\n' << '\n'; continue; } } else { // This is the last par Paragraph const & cpar = paragraphs.at(pit); - if (!cpar.empty() + if (!runparams.for_search && !cpar.empty() && cpar.isDeleted(0, cpar.size()) && !bparams.output_changes) { if (!cpar.parEndChange().deleted()) os << '\n' << '\n'; continue; }
pgplT5lvTgVne.pgp
Description: Digitale Signatur von OpenPGP
-- lyx-devel mailing list lyx-devel@lists.lyx.org http://lists.lyx.org/mailman/listinfo/lyx-devel