- // FIXME We do not really want this here, but it has to be at present
- // because we need a cursor for the recordUndoFullDocument call. What
- // we would really like is a recordUndoBufferParams call that did not
- // need a cursor, but we do not have that yet.
- // So, if this does get fixed, this code can be moved back to Buffer.cpp,
- // and the corresponding code in getStatus() should be moved back, too.
- case LFUN_BRANCH_ACTIVATE:
- case LFUN_BRANCH_DEACTIVATE:
- case LFUN_BRANCH_MASTER_ACTIVATE:
- case LFUN_BRANCH_MASTER_DEACTIVATE: {
- bool const master = (cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE
- || cmd.action() == LFUN_BRANCH_MASTER_DEACTIVATE);
- Buffer * buf = master ? const_cast<Buffer *>(buffer().masterBuffer())
- : &buffer();
-
- docstring const branch_name = cmd.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 activate = (cmd.action() == LFUN_BRANCH_ACTIVATE
- || cmd.action() == LFUN_BRANCH_MASTER_ACTIVATE);
- if (branch->isSelected() != activate) {
- branch->setSelected(activate);
- cur.recordUndoFullDocument();
- dr.setError(false);
- dr.screenUpdate(Update::Force);
- dr.forceBufferUpdate();
- }
- break;
- }
-