]> git.lyx.org Git - lyx.git/commitdiff
Improve reporting of undefined control sequences in preamble
authorJuergen Spitzmueller <spitz@lyx.org>
Sun, 19 Apr 2020 08:55:32 +0000 (10:55 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Sun, 19 Apr 2020 15:32:33 +0000 (17:32 +0200)
Fixes #11844

(cherry picked from commit 05c7c65d9345c4cd88b9c34b8e30beb96a268963)

src/LaTeX.cpp
status.23x

index e541361ee68cddbb11e245c36863c601239d1b6e..4be0dad4ab2051bdf76845c732d5ccdb478a7303 100644 (file)
@@ -840,10 +840,15 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                        // get the next line
                        string tmp;
                        int count = 0;
+                       // We also collect intermediate lines
+                       // This is needed for errors in preamble
+                       string intermediate;
                        do {
                                if (!getline(ifs, tmp))
                                        break;
                                tmp = rtrim(tmp, "\r");
+                               if (!prefixIs(tmp, "l."))
+                                       intermediate += tmp;
                                // 15 is somewhat arbitrarily chosen, based on practice.
                                // We used 10 for 14 years and increased it to 15 when we
                                // saw one case.
@@ -865,6 +870,15 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                sscanf(tmp.c_str(), "l.%d", &line);
                                // get the rest of the message:
                                string errstr(tmp, tmp.find(' '));
+                               bool preamble_error = false;
+                               if (suffixIs(errstr, "\\begin{document}")) {
+                                       // this is an error in preamble
+                                       // the real error is in the
+                                       // intermediate lines
+                                       errstr = intermediate;
+                                       tmp = intermediate;
+                                       preamble_error = true;
+                               }
                                errstr += '\n';
                                getline(ifs, tmp);
                                tmp = rtrim(tmp, "\r");
@@ -877,6 +891,9 @@ int LaTeX::scanLogFile(TeXErrors & terr)
                                        getline(ifs, tmp);
                                        tmp = rtrim(tmp, "\r");
                                }
+                               if (preamble_error)
+                                       // Add a note that the error is to be found in preamble
+                                       errstr += "\n" + to_utf8(_("(NOTE: The erroneous command is in the preamble)"));
                                LYXERR(Debug::LATEX, "line: " << line << '\n'
                                        << "Desc: " << desc << '\n' << "Text: " << errstr);
                                if (line == last_line)
index a6ead192bf285ae2412954bf46a0ea4d4e1e3d26..5a8ec3c575538a620b126d5603f4051b26407c29 100644 (file)
@@ -76,6 +76,14 @@ What's new
 
 * USER INTERFACE
 
+- Avoid crash in some cases where a dialog is shown during operation
+  (bug 11763).
+
+- Fix crash with nested insets when spaces are removed automatically (bug 11777).
+
+- Fix a crash reported on lyx users.
+  There was an uninitialized buffer member of MathData in LFUN dispatch.
+
 - Fix backspace deletion of selected items with change tracking (bug 11630).
 
 - Fix display glitch where the change tracking cue blinks with the cursor
@@ -85,9 +93,6 @@ What's new
 
 - Properly resize columns of child document table widget.
 
-- Fix a crash reported on lyx users.
-  There was an uninitialized buffer member of MathData in LFUN dispatch.
-
 - Fix problem with validation of InsetLayout.
 
 - Fix over-hasty resetting of dialog in Child Documents settings (bug 11564).
@@ -103,13 +108,11 @@ What's new
 - Disallow adding columns with gathered environment as this is not
   supported (bug 11812).
 
-- Preserve paragarph spacing when breaking a paragraph at the start
+- Preserve paragraph spacing when breaking a paragraph at the start
   (bug 11817).
 
-- Avoid crash in some cases where a dialog is shown during operation
-  (bug 11763).
+- Improve reporting of undefined control sequences in preamble (bug 11844).
 
-- Fix crash with nested insets when spaces are removed automatically (bug 11777).
 
 * INTERNALS