commit 56c4bf6c74255b43189002d4eecdd485caa1f8dc
Author: Jean-Marc Lasgouttes <[email protected]>
Date: Fri Jun 5 11:43:05 2015 +0200
Properly notify insets after BufferView::doDispatch
Currently, insets are notified that the cursor entered or leaved them
in Cursor::dispatch. This is not the case for lfuns which are handled
in BufferView.
Adding the proper code allows to fix many bugs where previews are not
updated correctly.
Fixes bug #6173.
diff --git a/src/BufferView.cpp b/src/BufferView.cpp
index 65d3683..0640898 100644
--- a/src/BufferView.cpp
+++ b/src/BufferView.cpp
@@ -1223,6 +1223,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()
@@ -1720,7 +1721,6 @@ 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()));
cur.selHandle(false);
@@ -2042,6 +2042,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();
+ }
}
diff --git a/src/Cursor.cpp b/src/Cursor.cpp
index 46fa261..29d4363 100644
--- a/src/Cursor.cpp
+++ b/src/Cursor.cpp
@@ -454,6 +454,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();
diff --git a/status.21x b/status.21x
index f94647c..0f4b417 100644
--- a/status.21x
+++ b/status.21x
@@ -70,6 +70,8 @@ What's new
- Fix setting of nested minipage via the dialog (bug 8716).
- When the document language is changed, update cursor language too (bug 9586).
+
+- Correctly update previews when cursor leaves inset (bug 6173).
* INTERNALS