Le 27/02/2017 à 18:41, Scott Kostyshak a écrit :
I'm often asked by LyX users why LyX behaves in the following way:1. Start math and type X to the power \alpha. 2. Inside the math inset, copy the contents. 3. Outside the math inset, paste. The text "X^{\alpha}" is pasted. The user seems to expect a math inset to be created and for it to contain X to the power alpha. The workaround is easy: just create a math inset before pasting (or in this case, select the entire math inset instead of its contents). However, enough users have asked me about this behavior and expressed their confusion, and I realized I don't know why we do it this way, since it seems uncommon that the user would actually want the LaTeX "X^{\alpha}". I understand if pasting outside of LyX, we need some plain-text representation, but when inside LyX, would it make sense to always create an inline math inset (e.g. even if the copy was made inside a display equation) and paste the contents in it? Is there a missing feature here? Scott
Yes, this annoys me too and I think this deserves a bug report. The selection is placed as application/x-lyx in the clipboard but the math selection is converted into a string before that. The problem is the use of grabSelection in copySelectionToStack in CutAndPaste.cpp which converts into a docstring. This part could be improved to keep the inset structure. As far as I can see this will not be immediate for multi-cell selections. For single-cell selections it should be simpler. For the alternative workaround you suggest, one could keep the string format but let ourselves know that it is tex math by giving it some mime type application/x-tex-math (which does not exist). Only then would we know that one has to create a math hull when pasting. The former is the proper way, the latter the simplest. Guillaume
