Improve reporting of undefined control sequences in preamble

Fixes #11844

(cherry picked from commit 05c7c65d93)
This commit is contained in:
Juergen Spitzmueller 2020-04-19 10:55:32 +02:00
parent 0696be89f1
commit a80ecb3820
2 changed files with 27 additions and 7 deletions

View 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)

View 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