]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Fix pasting as LaTeX in documents with no modules
[lyx.git] / src / Text3.cpp
index da23857c1ab6c4266099449cc1da0cfd7394ddb2..8bbac0eee23d72130b13b5e8ce6e143c98c623bb 100644 (file)
@@ -58,6 +58,7 @@
 #include "insets/InsetGraphics.h"
 #include "insets/InsetGraphicsParams.h"
 #include "insets/InsetInfo.h"
+#include "insets/InsetIndexMacro.h"
 #include "insets/InsetIPAMacro.h"
 #include "insets/InsetNewline.h"
 #include "insets/InsetQuotes.h"
@@ -914,12 +915,14 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_UP:
        case LFUN_DOWN: {
                // stop/start the selection
-               bool const select = cmd.action() == LFUN_DOWN_SELECT
-                                       || cmd.action() == LFUN_UP_SELECT;
+               bool select = cmd.action() == LFUN_DOWN_SELECT ||
+                       cmd.action() == LFUN_UP_SELECT;
+
                // move cursor up/down
-               bool const up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
+               bool up = cmd.action() == LFUN_UP_SELECT || cmd.action() == LFUN_UP;
+               bool const atFirstOrLastRow = cur.atFirstOrLastRow(up);
 
-               if (!cur.atFirstOrLastRow(up)) {
+               if (!atFirstOrLastRow) {
                        needsUpdate |= cur.selHandle(select);
                        cur.upDownInText(up, needsUpdate);
                        needsUpdate |= cur.beforeDispatchCursor().inMathed();
@@ -935,35 +938,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                                        cur.forceBufferUpdate();
                                break;
                        }
-                       needsUpdate |= cur.selHandle(select);
-                       bool const can_move = cur.upDownInText(up, needsUpdate);
-                       // if the cursor can be moved up or down at an upper level,
-                       // delegate the dispatch to next level. Otherwise, we are
-                       // done.
-                       if (can_move) {
-                               cmd = FuncRequest(up ? LFUN_FINISHED_UP : LFUN_FINISHED_DOWN);
-                               cur.undispatched();
-                       }
-               }
-
-               break;
-       }
-
-       case LFUN_FINISHED_UP:
-       case LFUN_FINISHED_DOWN: {
-               // move cursor up/down
-               bool const up = cmd.action() == LFUN_FINISHED_UP;
 
-               if (!cur.atFirstOrLastRow(up)) {
+                       // if the cursor cannot be moved up or down do not remove
+                       // the selection right now, but wait for the next dispatch.
+                       if (select)
+                               needsUpdate |= cur.selHandle(select);
                        cur.upDownInText(up, needsUpdate);
-                       needsUpdate |= cur.beforeDispatchCursor().inMathed();
-               } else {
-                       bool const can_move = cur.upDownInText(up, needsUpdate);
-                       // if the cursor can be moved up or down and we are not
-                       // moving cusor at top level, wait for the next dispatch.
-                       // Otherwise, we are done.
-                       if (can_move)
-                               cur.undispatched();
+                       cur.undispatched();
                }
 
                break;
@@ -2110,6 +2091,7 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
        case LFUN_BRANCH_INSERT:
        case LFUN_PHANTOM_INSERT:
        case LFUN_ERT_INSERT:
+       case LFUN_INDEXMACRO_INSERT:
        case LFUN_LISTING_INSERT:
        case LFUN_MARGINALNOTE_INSERT:
        case LFUN_ARGUMENT_INSERT:
@@ -3295,6 +3277,14 @@ bool Text::getStatus(Cursor & cur, FuncRequest const & cmd,
                }
                code = HYPERLINK_CODE;
                break;
+       case LFUN_INDEXMACRO_INSERT: {
+               string const arg = cmd.getArg(0);
+               if (arg == "sortkey")
+                       code = INDEXMACRO_SORTKEY_CODE;
+               else
+                       code = INDEXMACRO_CODE;
+               break;
+       }
        case LFUN_IPAMACRO_INSERT: {
                string const arg = cmd.getArg(0);
                if (arg == "deco")