* BufferView.cpp (moveToPosition): do not use ParIterator, which moves

through nested insets; what we want here is much simpler (bug 3472)


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@18254 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2007-05-10 07:53:00 +00:00
parent ae9afa946a
commit 5f7d6947e1

View File

@ -583,9 +583,12 @@ boost::tuple<pit_type, pos_type, int> BufferView::moveToPosition(pit_type bottom
ParIterator par = buffer_->getParFromID(top_id);
if (par != buffer_->par_iterator_end()) {
DocIterator dit = makeDocIterator(par, min(par->size(), top_pos));
// Some slices of the iterator may not be reachable (e.g. closed collapsable inset)
// so the dociterator may need to be shortened. Otherwise, setCursor may
// crash lyx when the cursor can not be set to these insets.
// Some slices of the iterator may not be
// reachable (e.g. closed collapsable inset)
// so the dociterator may need to be
// shortened. Otherwise, setCursor may crash
// lyx when the cursor can not be set to these
// insets.
size_t const n = dit.depth();
for (size_t i = 0; i < n; ++i)
if (dit[i].inset().editable() != Inset::HIGHLY_EDITABLE) {
@ -604,14 +607,12 @@ boost::tuple<pit_type, pos_type, int> BufferView::moveToPosition(pit_type bottom
// it will be restored to the left of the outmost inset that contains
// the bookmark.
if (static_cast<size_t>(bottom_pit) < buffer_->paragraphs().size()) {
ParIterator it = buffer_->par_iterator_begin();
ParIterator const end = buffer_->par_iterator_end();
for (; it != end; ++it)
if (it.pit() == bottom_pit) {
// restored pos may be bigger than it->size
setCursor(makeDocIterator(it, min(bottom_pos, it->size())));
return boost::make_tuple(bottom_pit, bottom_pos, it->id());
}
DocIterator it = doc_iterator_begin(buffer_->inset());
it.pit() = bottom_pit;
it.pos() = min(bottom_pos, it.paragraph().size());
setCursor(it);
return boost::make_tuple(it.pit(), it.pos(),
it.paragraph().id());
}
// both methods fail
return boost::make_tuple(pit_type(0), pos_type(0), 0);