]> git.lyx.org Git - lyx.git/blobdiff - src/BufferView.C
formatting
[lyx.git] / src / BufferView.C
index 48444b80d2027e39c9774111a5677ecf31390538..b1cfd99a49c111856ec1b9f8a51266cdea1cf0b1 100644 (file)
@@ -335,6 +335,10 @@ bool BufferView::multiParSel()
 
 bool BufferView::update(Update::flags flags)
 {
+       // last_inset_ points to the last visited inset. This pointer may become
+       // invalid becuase of keyboard editing. Since all such operations
+       // causes screen update(), I reset last_inset_ to avoid such a problem.
+       last_inset_ = 0;
        // This is close to a hot-path.
        if (lyxerr.debugging(Debug::DEBUG)) {
                lyxerr[Debug::DEBUG]
@@ -577,7 +581,6 @@ void BufferView::center()
        CursorSlice & bot = cursor_.bottom();
        TextMetrics & tm = text_metrics_[bot.text()];
        pit_type const pit = bot.pit();
-       int max_width = workWidth();
        tm.redoParagraph(pit);
        ParagraphMetrics const & pm = tm.parMetrics(pit);
        anchor_ref_ = pit;
@@ -1239,6 +1242,28 @@ void BufferView::setCursor(DocIterator const & dit)
 }
 
 
+bool BufferView::checkDepm(LCursor & cur, LCursor & old)
+{
+       // Would be wrong to delete anything if we have a selection.
+       if (cur.selection())
+               return false;
+
+       bool need_anchor_change = false;
+       bool changed = cursor_.text()->deleteEmptyParagraphMechanism(cur, old,
+               need_anchor_change);
+
+       if (need_anchor_change)
+               cur.resetAnchor();
+       
+       if (!changed)
+               return false;
+
+       updateMetrics(false);
+       buffer_->changed();
+       return true;
+}
+
+
 bool BufferView::mouseSetCursor(LCursor & cur)
 {
        BOOST_ASSERT(&cur.bv() == this);
@@ -1252,7 +1277,7 @@ bool BufferView::mouseSetCursor(LCursor & cur)
        // FIXME: move this to InsetText::notifyCursorLeaves?
        bool update = false;
        if (!badcursor && cursor_.inTexted())
-               update = cursor_.text()->deleteEmptyParagraphMechanism(cur, cursor_);
+               checkDepm(cur, cursor_);
 
        cursor_ = cur;
        cursor_.clearSelection();