On 06/06/2016 04:57 AM, Mario D wrote:
> After opening the dialog box to insert a reference to a label, when  a
> label is chosen there is a button  "Go to label" in order to check
> whether  the label is really the correct one. Good.
> After having hit this button, it is replaced with "Go back", so that I
> can get to the original point after having checked the label. Ok.
>
> The only drawback, in this, is that when I am back to the original
> point the label I checked is no longer selected, so that now I know
> whether it was the right one or not but, possibly, I don't remember
> its name...  :(
>
> Am I doing something wrong?

No, this is definitely a shortcoming. The attached patch fixes this
behavior, but it seems like a bit of a hack.

Anyone have a better idea? I could introduce a new variable for this
purpose, but that seems like overkill.

Richard

>From 302e23844b15b18d1cb0bb503ba45c4e895d973e Mon Sep 17 00:00:00 2001
From: Richard Heck <rgh...@lyx.org>
Date: Mon, 6 Jun 2016 19:36:27 -0400
Subject: [PATCH] Restore last selected label when using the "go to label"
 feature of the reference dialog.

---
 src/frontends/qt4/GuiRef.cpp | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/frontends/qt4/GuiRef.cpp b/src/frontends/qt4/GuiRef.cpp
index 1150d58..85e3553 100644
--- a/src/frontends/qt4/GuiRef.cpp
+++ b/src/frontends/qt4/GuiRef.cpp
@@ -114,7 +114,9 @@ void GuiRef::changed_adaptor()
 
 void GuiRef::gotoClicked()
 {
+	last_reference_ = referenceED->text();
 	gotoRef();
+	last_reference_.clear();
 }
 
 
@@ -417,19 +419,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;
-- 
2.1.0

Reply via email to