VCS InsetInfos were broken by the switch at 2e934fc5f8 to using
updateBuffer to handle them. But we do not really want to go through
that routine in a clone, not for those insets, whose contents we
want to be the same as in the original Buffer.

Also fixes some issues noted in discussion of this bug: Failure to
update after context menu switch; failure to re-calculate shortcuts,
which can change.
This commit is contained in:
Richard Heck 2017-12-28 14:41:47 -05:00
parent 60cb7a1683
commit d188a36fc2

View File

@ -247,6 +247,7 @@ void InsetInfo::doDispatch(Cursor & cur, FuncRequest & cmd)
case LFUN_INSET_MODIFY: case LFUN_INSET_MODIFY:
cur.recordUndo(); cur.recordUndo();
setInfo(to_utf8(cmd.argument())); setInfo(to_utf8(cmd.argument()));
cur.forceBufferUpdate();
initialized_ = false; initialized_ = false;
break; break;
@ -296,6 +297,14 @@ void InsetInfo::setText(docstring const & str)
void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) { void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
// If the Buffer is a clone, then we neither need nor want to do any
// of what follows. We want, rather, just to inherit how things were
// in the original Buffer. This is especially important for VCS.
// Otherwise, we could in principle have different settings here
// than in the Buffer we were exporting.
if (buffer().isClone())
return;
BufferParams const & bp = buffer().params(); BufferParams const & bp = buffer().params();
switch (type_) { switch (type_) {
@ -305,11 +314,7 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
break; break;
case SHORTCUT_INFO: case SHORTCUT_INFO:
case SHORTCUTS_INFO: { case SHORTCUTS_INFO: {
// only need to do this once. // shortcuts can change, so we need to re-do this each time
if (initialized_)
break;
// and we will not keep trying if we fail
initialized_ = true;
FuncRequest const func = lyxaction.lookupFunc(name_); FuncRequest const func = lyxaction.lookupFunc(name_);
if (func.action() == LFUN_UNKNOWN_ACTION) { if (func.action() == LFUN_UNKNOWN_ACTION) {
error("Unknown action %1$s"); error("Unknown action %1$s");
@ -328,7 +333,7 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
break; break;
} }
case LYXRC_INFO: { case LYXRC_INFO: {
// this information could actually change, if the preferences are changed, // this information could change, if the preferences are changed,
// so we will recalculate each time through. // so we will recalculate each time through.
ostringstream oss; ostringstream oss;
if (name_.empty()) { if (name_.empty()) {
@ -369,16 +374,13 @@ void InsetInfo::updateBuffer(ParIterator const & it, UpdateType utype) {
break; break;
case TEXTCLASS_INFO: { case TEXTCLASS_INFO: {
// only need to do this once. // the TextClass can change
if (initialized_)
break;
// name_ is the class name
LayoutFileList const & list = LayoutFileList::get(); LayoutFileList const & list = LayoutFileList::get();
bool available = false; bool available = false;
// name_ is the class name
if (list.haveClass(name_)) if (list.haveClass(name_))
available = list[name_].isTeXClassAvailable(); available = list[name_].isTeXClassAvailable();
setText(available ? _("yes") : _("no")); setText(available ? _("yes") : _("no"));
initialized_ = true;
break; break;
} }
case MENU_INFO: { case MENU_INFO: {