+ case LFUN_BRANCH_ACTIVATE:
+ case LFUN_BRANCH_DEACTIVATE:
+ case LFUN_BRANCH_MASTER_ACTIVATE:
+ case LFUN_BRANCH_MASTER_DEACTIVATE: {
+ bool const master = (func.action() == LFUN_BRANCH_MASTER_ACTIVATE
+ || func.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
+ Buffer * buf = master ? const_cast<Buffer *>(masterBuffer())
+ : this;
+
+ docstring const branch_name = func.argument();
+ // the case without a branch name is handled elsewhere
+ if (branch_name.empty()) {
+ dispatched = false;
+ break;
+ }
+ Branch * branch = buf->params().branchlist().find(branch_name);
+ if (!branch) {
+ LYXERR0("Branch " << branch_name << " does not exist.");
+ dr.setError(true);
+ docstring const msg =
+ bformat(_("Branch \"%1$s\" does not exist."), branch_name);
+ dr.setMessage(msg);
+ break;
+ }
+ bool const activate = (func.action() == LFUN_BRANCH_ACTIVATE
+ || func.action() == LFUN_BRANCH_MASTER_ACTIVATE);
+ if (branch->isSelected() != activate) {
+ buf->undo().recordUndoFullDocument(CursorData());
+ branch->setSelected(activate);
+ dr.setError(false);
+ dr.screenUpdate(Update::Force);
+ dr.forceBufferUpdate();
+ }
+ break;
+ }
+