placeables: Correctly insert at an existing parent if appropriate

At the end of a string (Case 2) the undo of a deletion of a placeable
(e.g. an XML tag) would be restored as plain text instead of part of
the existing tag. This is a reintroduction of bb04ce073 with updated
tests and error checking.
Simplify file discovery

This avoids a lot of unnecessary paths, while still allowing all ways
we expect it to work. This should help somewhat with startup performance
on both Linux and Windows.