Inspired by a recent thread on lyx-users, and because I have to do an index 
for a book myself ATM, I have fixed the behaviour of index insertion when 
there is text selected. By now, the selected text has been cut and pasted 
into the index inset, which does not make much sense (and is actually a bug 
IMO). The patch ensures that it is only copied. So if you have a word like 
lyx-devel, you can make an index entry by selecting it and do Indert->Index.

If there's interest, I'll also provide a patch for 1.4.

Jürgen
Index: text3.C
===================================================================
RCS file: /usr/local/lyx/cvsroot/lyx-devel/src/text3.C,v
retrieving revision 1.29.2.3
diff -u -r1.29.2.3 text3.C
--- text3.C	29 Dec 2003 13:27:26 -0000	1.29.2.3
+++ text3.C	25 Nov 2005 09:23:08 -0000
@@ -376,7 +376,7 @@
 }
 
 void doInsertInset(LyXText * lt, FuncRequest const & cmd,
-		   bool edit, bool pastesel)
+		   bool edit, bool pastesel, bool justcopy = false)
 {
 	Inset * inset = createInset(cmd);
 	BufferView * bv = cmd.view();
@@ -384,7 +384,10 @@
 	if (inset) {
 		bool gotsel = false;
 		if (lt->selection.set()) {
-			bv->owner()->dispatch(FuncRequest(LFUN_CUT));
+			if (justcopy)
+				bv->owner()->dispatch(FuncRequest(LFUN_COPY));
+			else
+				bv->owner()->dispatch(FuncRequest(LFUN_CUT));
 			gotsel = true;
 		}
 		if (bv->insertInset(inset)) {
@@ -1637,9 +1640,14 @@
 
 	case LFUN_INSERT_URL:
 	case LFUN_INSET_EXTERNAL:
-	case LFUN_INDEX_INSERT:
 		// Just open the inset
 		doInsertInset(this, cmd, true, false);
+		break;
+
+	case LFUN_INDEX_INSERT:
+		// Open the inset, and *copy* the current selection
+		// inside it.
+		doInsertInset(this, cmd, true, false, true);
 		break;
 
 	case LFUN_INDEX_PRINT:

Reply via email to