Keep shared markers consistent when documents are linked/unlinked

Issue #2360