]> git.lyx.org Git - lyx.git/commitdiff
Restore last selected label when using the "go to label" feature
authorRichard Heck <rgheck@lyx.org>
Mon, 6 Jun 2016 23:36:27 +0000 (19:36 -0400)
committerRichard Heck <rgheck@lyx.org>
Wed, 15 Jun 2016 21:32:53 +0000 (22:32 +0100)
of the reference dialog.

(cherry picked from commit 9d5ffa8e752213379d0ff611bd16deec1ab21c0a)

src/frontends/qt4/GuiRef.cpp
status.22x

index 1150d586b20efd01204755a944abd551d4f4c3f6..555ccce1a40a6a8aa094cc70b5f8b8feef4e7e6f 100644 (file)
@@ -114,7 +114,13 @@ void GuiRef::changed_adaptor()
 
 void GuiRef::gotoClicked()
 {
+       // By setting last_reference_, we ensure that the reference
+       // to which we are going (or from which we are returning) is
+       // restored in the dialog. It's a bit of a hack, but it works,
+       // and no-one seems to have any better idea.
+       last_reference_ = referenceED->text();
        gotoRef();
+       last_reference_.clear();
 }
 
 
@@ -417,19 +423,18 @@ void GuiRef::redoRefs()
                refsTW->addTopLevelItems(refsItems);
        }
 
-       referenceED->setText(oldSelection);
-
        // restore the last selection or, for new insets, highlight
        // the previous selection
        if (!oldSelection.isEmpty() || !last_reference_.isEmpty()) {
                bool const newInset = oldSelection.isEmpty();
                QString textToFind = newInset ? last_reference_ : oldSelection;
+               referenceED->setText(textToFind);
                last_reference_.clear();
                QTreeWidgetItemIterator it(refsTW);
                while (*it) {
                        if ((*it)->text(0) == textToFind) {
                                refsTW->setCurrentItem(*it);
-                               refsTW->setItemSelected(*it, !newInset);
+                               refsTW->setItemSelected(*it, true);
                                //Make sure selected item is visible
                                refsTW->scrollToItem(*it);
                                last_reference_ = textToFind;
index 6da8c02876b2a8ed316bba5f72de32ab664cdd40..bf985014f8fb4befdf368c2ca5a2f3113f2be0eb 100644 (file)
@@ -43,6 +43,9 @@ What's new
 - Implement "Dissolve Inset" and "Show Label" context menu items for
   arguments (bug 10150).
 
+- Restore selected reference when using "Go to label" and "Go back" in the
+  cross-reference dialog.
+
 
 * DOCUMENTATION AND LOCALIZATION