]> git.lyx.org Git - features.git/commitdiff
fix some rand cases
authorLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 5 Mar 2003 09:41:49 +0000 (09:41 +0000)
committerLars Gullik Bjønnes <larsbj@gullik.org>
Wed, 5 Mar 2003 09:41:49 +0000 (09:41 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@6349 a592a061-630c-0410-9148-cb99ea01b6c8

src/ChangeLog
src/ParagraphList.C
src/text.C

index 13b46ad221b1c36da1724d6a8fe3d11401446ed7..d7fb16c6099154789d97ccfa521379ce36f86c91 100644 (file)
@@ -1,3 +1,8 @@
+2003-03-05  Lars Gullik Bjønnes  <larsbj@gullik.net>
+
+       * ParagraphList.C (insert): handle insert right before end()
+       (erase): fix cases where it can be first or last paragraph.
+
 2003-03-04  Lars Gullik Bjønnes  <larsbj@gullik.net>
 
        * paragraph_funcs.C (TeXEnvironment): remove all usage of
index c462fd3d395b5bdc1b18aeec64c5469d1ba7858f..152aef2f5458d7d1a473673ab97f5afe867afcde 100644 (file)
@@ -88,11 +88,20 @@ ParagraphList::ParagraphList()
 ParagraphList::iterator
 ParagraphList::insert(ParagraphList::iterator it, Paragraph * par)
 {
-       Paragraph * prev = it->previous();
-       par->next(&*it);
-       par->previous(prev);
-       prev->next(par);
-       it->previous(par);
+       if (it != end()) {
+               Paragraph * prev = it->previous();
+               par->next(&*it);
+               par->previous(prev);
+               prev->next(par);
+               it->previous(par);
+       } else {
+               // Find last par.
+               Paragraph * last = parlist;
+               while (last->next())
+                       last = last->next();
+               last->next(par);
+               par->previous(last);
+       }
        return iterator(par);
 }
 
@@ -112,8 +121,10 @@ void ParagraphList::erase(ParagraphList::iterator it)
        Paragraph * prev = it->previous();
        Paragraph * next = it->next();
 
-       prev->next(next);
-       next->previous(prev);
+       if (prev)
+               prev->next(next);
+       if (next)
+               next->previous(prev);
 
        delete &*it;
 }
index baf693d5f4f8198478b083877075e785094ff8aa..8907e77b056a834f8a3ac819dfc0cb8f6e0d1729 100644 (file)
@@ -1406,6 +1406,10 @@ void LyXText::breakParagraph(BufferView * bview, char keep_layout)
 
        setHeightOfRow(bview, cursor.row());
 
+#warning Trouble Point! (Lgb)
+       // When ::breakParagraph is called from within an inset we must
+       // ensure that the correct ParagraphList is used. Today that is not
+       // the case and the Buffer::paragraphs is used. Not good. (Lgb)
        while (!cursor.par()->next()->empty()
          && cursor.par()->next()->isNewline(0))
           cursor.par()->next()->erase(0);