- if (!inset)
- return false;
-
- // don't relock if we're already locked
- if (theLockingInset() == inset)
- return true;
-
- if (theLockingInset())
- return theLockingInset()->lockInsetInInset(this, inset);
-
- // first check if it's the inset under the cursor we want lock
- // should be most of the time
- if (text->cursor.pos() < text->cursorPar()->size()
- && text->cursorPar()->getChar(text->cursor.pos()) ==
- Paragraph::META_INSET) {
- if (inset == text->cursorPar()->getInset(text->cursor.pos())) {
- theLockingInset(inset);
- return true;
- }
- }
-
- // then do a deep look at the inset and lock the right one
- ParagraphList::iterator pit = buffer()->paragraphs().begin();
- ParagraphList::iterator pend = buffer()->paragraphs().end();
- for (int par = 0; pit != pend; ++pit, ++par) {
- InsetList::iterator it = pit->insetlist.begin();
- InsetList::iterator end = pit->insetlist.end();
- for (; it != end; ++it) {
- if (it->inset == inset) {
- text->setCursorIntern(par, it->pos);
- theLockingInset(inset);
- return true;
- }
- }
- }
- return false;
-}
-
+ size_t const n = dit.depth();
+ for (size_t i = 0; i < n; ++i)
+ dit[i].inset().edit(cursor(), true);