I'd like to add these comments to warn others of problems I encountered when trying to use RemoveLineIfEmpty. I originally tried to fix the problem, but I realized I could implement the functionality more easily and efficiently in my calling code where I can make the simplifying assumption that there are no prior edits to the line from which text is being removed. While I've lost the motivation to write a fix, which doesn't look easy, I figure a warning to others is better than silence.
While I'm sure of the bug, some of these comments might be naive as I haven't fully digested the implementation here. If someone prefers to write entirely different comments or wants to fix the bug, I'm happy to abandon this patch.