Let errors-show open with the next error from current curson selected

This commit is contained in:
Juergen Spitzmueller 2025-01-05 14:14:06 +01:00
parent 08a747a750
commit d82e6d2bf0
5 changed files with 41 additions and 16 deletions

View File

@ -64,7 +64,8 @@ public:
/// This function is called when the buffer structure has been updated.
virtual void updateTocItem(std::string const &, DocIterator const &) = 0;
/// This function is called when some parsing error shows up.
virtual void errors(std::string const &, bool from_master = false) = 0;
virtual void errors(std::string const &, bool from_master = false,
int const item = -1) = 0;
/// This function is called when some message shows up.
virtual void message(docstring const &) = 0;
/// This function is called when the buffer busy status change.

View File

@ -24,6 +24,7 @@
#include "Text.h"
#include "TexRow.h"
#include "support/convert.h"
#include "support/debug.h"
#include "support/gettext.h"
#include "support/lstrings.h"
@ -125,7 +126,7 @@ void GuiErrorList::paramsToDialog()
ErrorList::const_iterator const en = el.end();
for (; it != en; ++it)
errorsLW->addItem(toqstr(it->error));
errorsLW->setCurrentRow(0);
errorsLW->setCurrentRow(item_);
showAnywayPB->setEnabled(
lyx::getStatus(FuncRequest(LFUN_BUFFER_VIEW_CACHE)).enabled());
}
@ -149,6 +150,12 @@ bool GuiErrorList::initialiseParams(string const & sdata)
string error_type = sdata;
if (from_master_)
error_type = split(sdata, '|');
if (contains(error_type, "@")) {
string tmp;
string const s = split(error_type, tmp, '@');
error_type = tmp;
item_ = convert<int>(s);
}
error_type_ = error_type;
buf_ = from_master_ ?
bufferview()->buffer().masterBuffer()

View File

@ -65,6 +65,8 @@ private:
docstring name_;
///
bool from_master_;
///
int item_ = 0;
};
} // namespace frontend

View File

@ -2172,7 +2172,7 @@ void GuiView::disconnectBufferView()
}
void GuiView::errors(string const & error_type, bool from_master)
void GuiView::errors(string const & error_type, bool from_master, int const item)
{
BufferView const * const bv = currentBufferView();
if (!bv)
@ -2188,15 +2188,18 @@ void GuiView::errors(string const & error_type, bool from_master)
string err = error_type;
if (from_master)
err = "from_master|" + error_type;
if (item != -1)
err += "@" + convert<string>(item);
showDialog("errorlist", err);
}
bool GuiView::nextError(string const & error_type, bool from_master, bool testonly)
int GuiView::nextError(string const & error_type, bool from_master,
bool navigateto, bool atcursor)
{
BufferView const * const bv = currentBufferView();
if (!bv)
return false;
return -1;
Buffer const & buf = from_master
? *(bv->buffer().masterBuffer())
@ -2205,19 +2208,24 @@ bool GuiView::nextError(string const & error_type, bool from_master, bool teston
ErrorList const & el = buf.errorList(error_type);
if (el.empty())
return false;
return -1;
int item = 0;
for (auto const & err : el) {
if (TexRow::isNone(err.start) || TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first <= bv->cursor())
if (TexRow::isNone(err.start)
|| (atcursor && TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first < bv->cursor())
|| (!atcursor && TexRow::getDocIteratorsFromEntries(err.start, err.end, buf).first <= bv->cursor())) {
++item;
continue;
if (!testonly) {
}
if (navigateto) {
DispatchResult dr;
dispatch(TexRow::goToFunc(err.start, err.end), dr);
}
return true;
return item;
}
return false;
return -1;
}
@ -2716,7 +2724,7 @@ bool GuiView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
}
// We guess it's from master if the single buffer list is empty
bool const from_master = currentBufferView()->buffer().errorList(d.last_export_format).empty();
enable = nextError(d.last_export_format, from_master, true);
enable = nextError(d.last_export_format, from_master) != -1;
break;
}
@ -4966,14 +4974,14 @@ void GuiView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
case LFUN_ERRORS_SHOW: {
// We guess it's from master if the single buffer list is empty
bool const from_master = bv->buffer().errorList(d.last_export_format).empty();
errors(d.last_export_format, from_master);
errors(d.last_export_format, from_master, nextError(d.last_export_format, from_master, false, true));
break;
}
case LFUN_ERROR_NEXT: {
// We guess it's from master if the single buffer list is empty
bool const from_master = bv->buffer().errorList(d.last_export_format).empty();
if (nextError(d.last_export_format, from_master)) {
if (nextError(d.last_export_format, from_master, true) != -1) {
dr.forceBufferUpdate();
dr.screenUpdate(Update::Force);
}

View File

@ -172,13 +172,20 @@ public:
void resetAutosaveTimers() override;
// shows an error list
// if from_master is true, show master's error list
void errors(std::string const &, bool from_master = false) override;
void errors(std::string const &, bool from_master = false,
int const item = -1) override;
void structureChanged() override;
void updateTocItem(std::string const &, DocIterator const &) override;
//@}
/// move to next error
bool nextError(std::string const &, bool from_master = false, bool testonly = false);
/** Find the next error from current cursor position.
* \return the error item position in the error list
* with \param navigateto the cursor moves to the error
* with \param atcursor the error at current cursor position
* is considered as well, otherwise only those who follow.
*/
int nextError(std::string const & error_type, bool from_master = false,
bool navigateto = false, bool atcursor = false);
///
TocModels & tocModels();