]> git.lyx.org Git - features.git/commitdiff
Properly notify insets after BufferView::doDispatch
authorJean-Marc Lasgouttes <lasgouttes@lyx.org>
Fri, 5 Jun 2015 09:43:05 +0000 (11:43 +0200)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Mon, 8 Jun 2015 13:10:36 +0000 (15:10 +0200)
Currently, insets are notified that the cursor entered or leaved them in Cursor::dispatch. This is not the cas efor lfuns which are handled in BufferView.

Adding the proper code allows to fix many bugs where previews are not updated correctly.

This also reverts cf4f79f8, which was the same fix for a particular case.

Fixes bug #6173.

src/BufferView.cpp
src/Cursor.cpp

index b2478a001468dcf6f4187150869a8f4a9a89bd64..41d85bf400058b651e67b374c7e2785087cc5cb9 100644 (file)
@@ -1237,6 +1237,7 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        string const argument = to_utf8(cmd.argument());
        Cursor & cur = d->cursor_;
+       Cursor old = cur;
 
        // Don't dispatch function that does not apply to internal buffers.
        if (buffer_.isInternal()
@@ -1745,11 +1746,8 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                        p = Point(0, 0);
                if (act == LFUN_SCREEN_DOWN && scrolled < height_)
                        p = Point(width_, height_);
-               Cursor old = cur;
                bool const in_texted = cur.inTexted();
                cur.setCursor(doc_iterator_begin(cur.buffer()));
-               if (cur != old)
-                       notifyCursorLeavesOrEnters(old, cur);
                cur.selHandle(false);
                buffer_.changed(true);
                updateHoveredInset();
@@ -2069,6 +2067,21 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
 
        buffer_.undo().endUndoGroup();
        dr.dispatched(dispatched);
+
+       // NOTE: The code below is copied from Cursor::dispatch. If you
+       // need to modify this, please update the other one too.
+
+       // notify insets we just entered/left
+       if (cursor() != old) {
+               old.beginUndoGroup();
+               old.fixIfBroken();
+               bool badcursor = notifyCursorLeavesOrEnters(old, cursor());
+               if (badcursor) {
+                       cursor().fixIfBroken();
+                       resetInlineCompletionPos();
+               }
+               old.endUndoGroup();
+       }
 }
 
 
index 44457e335febd772ace8f617ba4a1d8bca3df6ad..6e011bccf9a427a6be4f7614ae108dbecc94f0e5 100644 (file)
@@ -458,6 +458,9 @@ void Cursor::dispatch(FuncRequest const & cmd0)
        }
        endUndoGroup();
 
+       // NOTE: The code below has been copied to BufferView::dispatch.
+       // If you need to modify this, please update the other one too.
+
        // notify insets we just left
        if (*this != old) {
                old.beginUndoGroup();