Dear list, The attached patches add safe line breaks ("%\n") to the output, to crucially increase the precision of forward/reverse-search and error reporting of captions. This is especially useful as these captions introduce a discontinuity in the TexRow. The change is trivial but since this modifies the LaTeX output I prefer to ask for any objection.
I also tried once again to read section "4.3 ctest automatic tests" of the developer's manual and I am still at a loss to understand what the tests do or to know how to run just the ones that are relevant to these two patches. I am ready to adjust the test afterwards if there are reports of tests needing such adjustment. Sincerely, Guillaume
>From f97a870a2f77229876e12d77bf727505ae42aa84 Mon Sep 17 00:00:00 2001 From: Guillaume Munch <g...@lyx.org> Date: Mon, 10 Oct 2016 16:52:32 +0200 Subject: [PATCH 1/2] Safe line break to increase precision of error reporting in Listings caption --- src/insets/InsetListings.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/insets/InsetListings.cpp b/src/insets/InsetListings.cpp index 8211ba3..62250fe 100644 --- a/src/insets/InsetListings.cpp +++ b/src/insets/InsetListings.cpp @@ -227,7 +227,7 @@ void InsetListings::latex(otexstream & os, OutputParams const & runparams) const if (param_string.empty() && caption.str.empty()) os << breakln << "\\begin{lstlisting}\n"; else { - os << breakln << "\\begin{lstlisting}["; + os << breakln << "\\begin{lstlisting}" << safebreakln << "["; if (!caption.str.empty()) { os << "caption={" << move(caption) << '}'; if (!param_string.empty()) -- 2.7.4
>From 4e82c33d8c6bc35e47dfea0bfced9656a1dc9d39 Mon Sep 17 00:00:00 2001 From: Guillaume Munch <g...@lyx.org> Date: Mon, 10 Oct 2016 17:14:39 +0200 Subject: [PATCH 2/2] Add safe line breaks to improve TexRow precision in subfloat & caption --- src/insets/InsetFloat.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp index 1030b45..e974ff4 100644 --- a/src/insets/InsetFloat.cpp +++ b/src/insets/InsetFloat.cpp @@ -324,6 +324,10 @@ docstring InsetFloat::xhtml(XHTMLStream & xs, OutputParams const & rp) const void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const { if (runparams_in.inFloat != OutputParams::NONFLOAT) { + if (!paragraphs().empty()) + // improve TexRow precision + os << safebreakln; + if (runparams_in.moving_arg) os << "\\protect"; os << "\\subfloat"; @@ -333,8 +337,6 @@ void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const os << getCaption(rp); os << '{'; // The main argument is the contents of the float. This is not a moving argument. - if (!paragraphs().empty()) - os.texrow().forceStart(paragraphs()[0].id(), 0); rp.moving_arg = false; rp.inFloat = OutputParams::SUBFLOAT; InsetText::latex(os, rp); @@ -503,7 +505,7 @@ TexString InsetFloat::getCaption(OutputParams const & runparams) const otexstringstream os; ins->getArgs(os, runparams); - os << '['; + os << safebreakln << '['; otexstringstream os2; ins->getArgument(os2, runparams); TexString ts = os2.release(); @@ -512,7 +514,7 @@ TexString InsetFloat::getCaption(OutputParams const & runparams) const if (arg.find(']') != docstring::npos) arg = '{' + arg + '}'; os << move(ts); - os << ']'; + os << ']' << safebreakln; return os.release(); } -- 2.7.4