namespace {
bool gotoNextInset(LCursor & cur,
- vector<InsetBase_code> const & codes,
+ vector<InsetBase_code> const & codes,
string const & contents)
{
LCursor tmpcur = cur;
-
+
while (tmpcur) {
InsetBase const * inset = tmpcur.nextInset();
- if (inset
- && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
+ if (inset
+ && find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()
&& (contents.empty() ||
static_cast<InsetCommand const *>(inset)->getContents() == contents)) {
cur = tmpcur;
}
-void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes,
+void gotoInset(BufferView * bv, vector<InsetBase_code> const & codes,
bool same_content)
{
string contents;
if (same_content) {
InsetBase const * inset = tmpcur.nextInset();
- if (inset
+ if (inset
&& find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end()) {
contents = static_cast<InsetCommand const *>(inset)->getContents();
}
}
if (!gotoNextInset(tmpcur, codes, contents)) {
- if (tmpcur != doc_iterator_begin(tmpcur.inset())) {
+ if (bv->cursor() != doc_iterator_begin(bv->buffer()->inset())) {
tmpcur.reset(tmpcur.bottom().inset());
- if (!gotoNextInset(tmpcur, codes, contents))
+ if (!gotoNextInset(tmpcur, codes, contents)) {
bv->cursor().message(_("No more insets"));
+ return;
+ }
} else {
bv->cursor().message(_("No more insets"));
+ return;
}
}
-
+
tmpcur.clearSelection();
bv->setCursor(tmpcur);
}