I have made a suggestion of how spaces at the end of lines could be handled:
https://www.lyx.org/trac/ticket/10117#comment:34 But I am unsure. Was there a discussion of this before?(As I mention in the comment, my engagement with this is purely theoretical. But I hope that might still be useful.)
Daniel