On Wed, 2006-10-25 at 14:06 +0200, Jean-Marc Lasgouttes wrote:
> >>>>> "Martin" == Martin Vermeer <[EMAIL PROTECTED]> writes:
> 
> Martin> I believe so. Possibly newpit includes [pit=4], I'm not quite
> Martin> sure (does it matter?)
> 
> Is it why you need to use min/max? I think you should not need that. I
> would try without pit=4 first, and then add it if it seems necessary
> :)
> 
> The crash recipe: make a document with only two Section paragraphs. Do
> a 'down' of the first one.
> 
> JMarc

Yes, I found that too.

Attached doesn't crash anymore.

You're probably right about not needing std::min. I'm going to try that
next ;-)

About names, what would you suggest?

s = start
p = finish
q = dest

?

Better ideas?

- Martin

Index: toc.C
===================================================================
--- toc.C	(revision 15477)
+++ toc.C	(working copy)
@@ -170,7 +170,6 @@
 
 void outline(OutlineOp mode,  LCursor & cur)
 {
-	recordUndo(cur);
 	Buffer * buf = & cur.buffer();
 	pit_type & pit = cur.pit();
 	ParagraphList & pars = buf->text().paragraphs();
@@ -212,6 +211,8 @@
 			pit_type const newpit = std::distance(pars.begin(), q);
 			pit_type const len = std::distance(s, p);
 			pit += len;
+			pit = std::min(pit, cur.lastpit());
+			recordUndo(cur, Undo::ATOMIC, newpit, pit);
 			pars.insert(q, s, p);
 			s = boost::next(pars.begin(), pit);
 			ParagraphList::iterator t = boost::next(s, len);
@@ -241,8 +242,10 @@
 					break;	
 				}
 			}
-			pit_type const newpit = std::distance(pars.begin(), q);
+			pit_type newpit = std::distance(pars.begin(), q);
 			pit_type const len = std::distance(s, p);
+			newpit = std::min(newpit, cur.lastpit());
+			recordUndo(cur, Undo::ATOMIC, pit, newpit);
 			pars.insert(q, s, p);
 			s = boost::next(pars.begin(), pit);
 			ParagraphList::iterator t = boost::next(s, len);
@@ -251,6 +254,7 @@
 		break;
 		}
 		case In:
+			recordUndo(cur);
 			for (; lit != lend; ++lit) {
 				if ((*lit)->toclevel == thistoclevel + 1 &&
 				    s->layout()->labeltype == (*lit)->labeltype) {
@@ -260,6 +264,7 @@
 			}
 		break;
 		case Out:
+			recordUndo(cur);
 			for (; lit != lend; ++lit) {
 				if ((*lit)->toclevel == thistoclevel - 1 &&
 				    s->layout()->labeltype == (*lit)->labeltype) {

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to