]> git.lyx.org Git - features.git/commitdiff
Deal with the part of #7872 involving changes of branch activation
authorRichard Heck <rgheck@comcast.net>
Fri, 2 Dec 2011 21:21:30 +0000 (21:21 +0000)
committerRichard Heck <rgheck@comcast.net>
Fri, 2 Dec 2011 21:21:30 +0000 (21:21 +0000)
from Document>Settings.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@40333 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/BufferView.cpp

index cd3dcb85a7d33fe43f3eb6a04d827f7e6d653260..dea663e65f1e94830430a11d595ef15527f0f747 100644 (file)
@@ -2102,14 +2102,6 @@ bool Buffer::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                        enable = params().isExportable("program");
                        break;
 
-               case LFUN_BRANCH_ACTIVATE: 
-               case LFUN_BRANCH_DEACTIVATE: {
-                       BranchList const & branchList = params().branchlist();
-                       docstring const branchName = cmd.argument();
-                       enable = !branchName.empty() && branchList.find(branchName);
-                       break;
-               }
-
                case LFUN_BRANCH_ADD:
                case LFUN_BRANCHES_RENAME:
                case LFUN_BUFFER_PRINT:
@@ -2261,36 +2253,7 @@ void Buffer::dispatch(FuncRequest const & func, DispatchResult & dr)
                break;
        }
 
-       case LFUN_BRANCH_ACTIVATE:
-       case LFUN_BRANCH_DEACTIVATE: {
-               BranchList & branchList = params().branchlist();
-               docstring const branchName = func.argument();
-               // the case without a branch name is handled elsewhere
-               if (branchName.empty()) {
-                       dispatched = false;
-                       break;
-               }
-               Branch * branch = branchList.find(branchName);
-               if (!branch) {
-                       LYXERR0("Branch " << branchName << " does not exist.");
-                       dr.setError(true);
-                       docstring const msg = 
-                               bformat(_("Branch \"%1$s\" does not exist."), branchName);
-                       dr.setMessage(msg);
-                       break;
-               }
-               bool activate = func.action() == LFUN_BRANCH_ACTIVATE;
-               if (branch->isSelected() != activate) {
-                       branch->setSelected(activate);
-                       markDirty();
-                       dr.setError(false);
-                       dr.screenUpdate(Update::Force);
-                       dr.forceBufferUpdate();
-               }
-               break;
-       }
-
-       case LFUN_BRANCHES_RENAME: {
+               case LFUN_BRANCHES_RENAME: {
                if (func.argument().empty())
                        break;
 
index 178bcfc521ec507a4adce27a287396b941af0815..5b604c0e7bb93a87932fe44614009ccf4058ee2b 100644 (file)
@@ -1160,6 +1160,17 @@ bool BufferView::getStatus(FuncRequest const & cmd, FuncStatus & flag)
                break;
        }
 
+       // FIXME We do not really want this here, but at present we need to
+       // handle their dispatch here, for reasons explained there, so we'll
+       // handle this here, too, for consistency.
+       case LFUN_BRANCH_ACTIVATE:
+       case LFUN_BRANCH_DEACTIVATE: {
+               BranchList const & branchList = buffer().params().branchlist();
+               docstring const branchName = cmd.argument();
+               flag.setEnabled(!branchName.empty() && branchList.find(branchName));
+               break;
+       }
+
        default:
                return false;
        }
@@ -1909,6 +1920,41 @@ void BufferView::dispatch(FuncRequest const & cmd, DispatchResult & dr)
                break;
        }
 
+       // 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: {
+               BranchList & branch_list = buffer().params().branchlist();
+               docstring const branch_name = cmd.argument();
+               // the case without a branch name is handled elsewhere
+               if (branch_name.empty()) {
+                       dispatched = false;
+                       break;
+               }
+               Branch * branch = branch_list.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;
+               if (branch->isSelected() != activate) {
+                       branch->setSelected(activate);
+                       cur.recordUndoFullDocument();
+                       dr.setError(false);
+                       dr.screenUpdate(Update::Force);
+                       dr.forceBufferUpdate();
+               }
+               break;
+       }
+
        default:
                // OK, so try the Buffer itself...
                buffer_.dispatch(cmd, dr);