- } while (res.par() &&
- !(res.par()->isInset(res.pos())
- && (inset = res.par()->getInset(res.pos())) != 0
- && find(codes.begin(), codes.end(), inset->lyxCode())
- != codes.end()
- && (contents.empty() ||
- static_cast<InsetCommand *>(
- res.par()->getInset(res.pos()))->getContents()
- == contents)));
-
- if (res.par()) {
- setCursor(bv, res.par(), res.pos(), false);
+ } while (pit != end &&
+ !(pit->isInset(pos) &&
+ (inset = pit->getInset(pos)) != 0 &&
+ find(codes.begin(), codes.end(), inset->lyxCode()) != codes.end() &&
+ (contents.empty() ||
+ static_cast<InsetCommand *>(pit->getInset(pos))->getContents()
+ == contents)));
+
+ if (pit != end) {
+ setCursor(pit, pos, false);