]> git.lyx.org Git - features.git/commitdiff
Do not propose existing labels
authorJuergen Spitzmueller <spitz@lyx.org>
Wed, 19 Sep 2012 08:20:19 +0000 (10:20 +0200)
committerJuergen Spitzmueller <spitz@lyx.org>
Wed, 19 Sep 2012 08:20:19 +0000 (10:20 +0200)
src/Text.cpp

index a2f69922032510a73c251bddf9bdcd30b61efde2..c61e9e1bb1f87a55e7c27b5f73b7fad6d6507cca 100644 (file)
@@ -60,6 +60,7 @@
 #include "insets/InsetSpecialChar.h"
 #include "insets/InsetTabular.h"
 
+#include "support/convert.h"
 #include "support/debug.h"
 #include "support/docstream.h"
 #include "support/gettext.h"
@@ -1955,7 +1956,15 @@ docstring Text::getPossibleLabel(Cursor const & cur) const
        if (!name.empty())
                text = name + ':' + text;
 
-       return text;
+       // We need a unique label
+       docstring label = text;
+       int i = 1;
+       while (cur.buffer()->insetLabel(label)) {
+                       label = text + '-' + convert<docstring>(i);
+                       ++i;
+               }
+
+       return label;
 }