]> git.lyx.org Git - lyx.git/commitdiff
When an error occurs, don't highlight more than necessary.
authorEnrico Forestieri <forenr@lyx.org>
Sat, 12 Mar 2011 01:40:01 +0000 (01:40 +0000)
committerEnrico Forestieri <forenr@lyx.org>
Sat, 12 Mar 2011 01:40:01 +0000 (01:40 +0000)
Currently, if an inset outputs a newline, the new latex row is still
associated with a previous id/pos. Now, if a latex error occurs before
this newline, we would still highlight everything associated to that
id/pos, even if it is extraneous to the error.
This is avoided by associating the new latex row with the id/pos in
effect right before entering the inset. If an inset does not output
a newline, it is not excluded from the selection, consistent with the
fact that the text of the inset does appear in the error description.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@37903 a592a061-630c-0410-9148-cb99ea01b6c8

src/OutputParams.cpp
src/OutputParams.h
src/Paragraph.cpp
src/insets/InsetBox.cpp
src/insets/InsetFloat.cpp
src/insets/InsetFoot.cpp
src/insets/InsetTabular.cpp
src/insets/InsetText.cpp
src/mathed/InsetMathNest.cpp

index 3ef6c7ace851d416c80a927efde680206080e682..dc3d396426a7bf81359feba25c4e5b652b11a365 100644 (file)
@@ -27,7 +27,7 @@ OutputParams::OutputParams(Encoding const * enc)
          inComment(false), inTableCell(NO), inFloat(NONFLOAT),
          inIndexEntry(false), inDeletedInset(0),
          changeOfDeletedInset(Change::UNCHANGED),
-         par_begin(0), par_end(0), isLastPar(false),
+         par_begin(0), par_end(0), lastid(-1), lastpos(-1), isLastPar(false),
          dryrun(false), pass_thru(false), 
          html_disable_captions(false), html_in_par(false),
          html_make_pars(true), for_toc(false), includeall(false)
index c9129eae3e9dd1d805ccb5d719c884e8d4a52d0d..50009ebbbcf6461b261188bbcb29c16a93cdde51 100644 (file)
@@ -218,6 +218,12 @@ public:
         */
        mutable pit_type par_end;
 
+       /// Id of the last paragraph before an inset
+       mutable int lastid;
+
+       /// Last position in the last paragraph before an inset
+       mutable int lastpos;
+
        /// is this the last paragraph in the current buffer/inset?
        bool isLastPar;
        
index 9f3fb5ec982f4b71e6a4dc6533a05c8081cb4663..d5f4a5869c0810acb4a6a0a15db43c3ea48781e2 100644 (file)
@@ -1117,6 +1117,8 @@ void Paragraph::Private::latexInset(BufferParams const & bparams,
        int prev_rows = os.texrow().rows();
 
        try {
+               runparams.lastid = id_;
+               runparams.lastpos = i;
                inset->latex(os, runparams);
        } catch (EncodingException & e) {
                // add location information and throw again.
index 9999426444cbc2224d7ab5f4674c2c0dc10923a0..1273ac9e082ccdce10556ce8ddccec4e43e845b6 100644 (file)
@@ -271,7 +271,10 @@ void InsetBox::latex(otexstream & os, OutputParams const & runparams) const
                }
        }
 
-       os << "%\n";
+       os << safebreakln;
+       if (runparams.lastid != -1)
+               os.texrow().start(runparams.lastid, runparams.lastpos);
+
        // Adapt to column/text width correctly also if paragraphs indented:
        if (stdwidth)
                os << "\\noindent";
index e3876ba1c3305597046967a17fbd53dc0f2cf434..a1bddb0a22f0ac0d228a60466f7f48a5f0b580fb 100644 (file)
@@ -374,6 +374,8 @@ void InsetFloat::latex(otexstream & os, OutputParams const & runparams_in) const
 
        // Force \begin{<floatname>} to appear in a new line.
        os << breakln << "\\begin{" << from_ascii(tmptype) << '}';
+       if (runparams.lastid != -1)
+               os.texrow().start(runparams.lastid, runparams.lastpos);
        // We only output placement if different from the def_placement.
        // sidewaysfloats always use their own page
        if (!placement.empty() && !params_.sideways)
index d7eee84175fc0736d274181013d8d99ade14cd54..489358a110a98660e10a3c603ec542496bdf3c40 100644 (file)
@@ -90,12 +90,16 @@ void InsetFoot::latex(otexstream & os, OutputParams const & runparams_in) const
        // footnotes in titling commands like \title have moving arguments
        runparams.moving_arg |= runparams_in.intitle;
 
+       os << safebreakln;
+       if (runparams.lastid != -1)
+               os.texrow().start(runparams.lastid, runparams.lastpos);
+
        // in titling commands, \thanks should be used instead of \footnote.
        // some classes (e.g. memoir) do not understand \footnote.
        if (runparams_in.intitle)
-               os << "%\n\\thanks{";
+               os << "\\thanks{";
        else
-               os << "%\n\\footnote{";
+               os << "\\footnote{";
 
        InsetText::latex(os, runparams);
        os << "%\n}";
index 8c9824161ecb2cb5d91afe9a71af35bbab611df2..948cad58d67dda2209224ef71a6b16ad1cec948c 100644 (file)
@@ -2563,6 +2563,10 @@ void Tabular::latex(otexstream & os, OutputParams const & runparams) const
        //+                      first the opening preamble                    +
        //+---------------------------------------------------------------------
 
+       os << safebreakln;
+       if (runparams.lastid != -1)
+               os.texrow().start(runparams.lastid, runparams.lastpos);
+
        if (rotate)
                os << "\\begin{sideways}\n";
 
index e9105080a6cbbf567163978550597ce5c0044f45..f0a6c81832ffcc4ee088084fa10810b7ff3a6cb0 100644 (file)
@@ -391,6 +391,9 @@ void InsetText::latex(otexstream & os, OutputParams const & runparams) const
                            os << breakln;
                        else
                            os << safebreakln;
+                       if (runparams.lastid != -1)
+                               os.texrow().start(runparams.lastid,
+                                                 runparams.lastpos);
                        os << "\\begin{" << from_utf8(il.latexname()) << "}\n";
                        if (!il.latexparam().empty())
                                os << from_utf8(il.latexparam());
index edbe99aea08ccdd904a642debc75f98a2688459e..438039196fb903c6335b14ac5e79b133669775e1 100644 (file)
@@ -402,7 +402,14 @@ void InsetMathNest::latex(otexstream & os, OutputParams const & runparams) const
        wi.canBreakLine(os.canBreakLine());
        write(wi);
        os.canBreakLine(wi.canBreakLine());
-       os.texrow().newlines(wi.line());
+
+       int lf = wi.line();
+       if (lf > 0 && runparams.lastid != -1) {
+               --lf;
+               os.texrow().newline();
+               os.texrow().start(runparams.lastid, runparams.lastpos);
+       }
+       os.texrow().newlines(lf);
 }