]> git.lyx.org Git - lyx.git/blobdiff - src/Text3.cpp
Avoid infinite loop
[lyx.git] / src / Text3.cpp
index 918064c3363728a5306a07689724b399eb21fe77..9cef6692b44812c60fc82a6f1f7493785e8a82d7 100644 (file)
@@ -1663,8 +1663,13 @@ void Text::dispatch(Cursor & cur, FuncRequest & cmd)
                        DocIterator scur = cur;
                        depth_type const max_depth = cur.paragraph().params().depth() + 1;
                        cur.forwardPar();
-                       while (cur.paragraph().params().depth() < min(nextpar_depth, max_depth))
+                       while (cur.paragraph().params().depth() < min(nextpar_depth, max_depth)) {
+                               depth_type const olddepth = cur.paragraph().params().depth();
                                lyx::dispatch(FuncRequest(LFUN_DEPTH_INCREMENT));
+                               if (olddepth == cur.paragraph().params().depth())
+                                       // leave loop if no incrementation happens
+                                       break;
+                       }
                        cur.setCursor(scur);
                }