On Wed, 2006-10-25 at 15:35 +0300, Martin Vermeer wrote:
> On Wed, 2006-10-25 at 15:12 +0300, Martin Vermeer wrote:
> > 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 ;-)
> 
> Yes, and works. Attached.
> 
> If you don't get this to crash, I propose to commit it. 
> 
> > About names, what would you suggest?
> > 
> > s = start
> > p = finish
> > q = dest
> > 
> > ?
> > 
> > Better ideas?
> 
> I will then do this job separately.
> 
> - Martin

Or even simpler...

- 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();
@@ -209,11 +208,12 @@
 					break;	
 				}
 			}
-			pit_type const newpit = std::distance(pars.begin(), q);
+			pit_type const newpit = std::distance(bgn, q);
 			pit_type const len = std::distance(s, p);
 			pit += len;
+			recordUndo(cur, Undo::ATOMIC, newpit, pit - 1);
 			pars.insert(q, s, p);
-			s = boost::next(pars.begin(), pit);
+			s = boost::next(bgn, pit);
 			ParagraphList::iterator t = boost::next(s, len);
 			pit = newpit;
 			pars.erase(s, t);
@@ -241,16 +241,18 @@
 					break;	
 				}
 			}
-			pit_type const newpit = std::distance(pars.begin(), q);
+			pit_type newpit = std::distance(bgn, q);
 			pit_type const len = std::distance(s, p);
+			recordUndo(cur, Undo::ATOMIC, pit, newpit - 1);
 			pars.insert(q, s, p);
-			s = boost::next(pars.begin(), pit);
+			s = boost::next(bgn, pit);
 			ParagraphList::iterator t = boost::next(s, len);
 			pit = newpit - len;
 			pars.erase(s, t);
 		break;
 		}
 		case In:
+			recordUndo(cur);
 			for (; lit != lend; ++lit) {
 				if ((*lit)->toclevel == thistoclevel + 1 &&
 				    s->layout()->labeltype == (*lit)->labeltype) {
@@ -260,6 +262,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