{
Buffer * buf = &documentBufferView()->buffer();
FileName filename = buf->fileName();
+ Buffer const * master = buf->masterBuffer();
+ bool const is_child = master != buf;
// The user has already confirmed that the changes, if any, should
// be discarded. So we just release the Buffer and don't call closeBuffer();
theBufferList().release(buf);
buf = loadDocument(filename);
docstring const disp_fn = makeDisplayPath(filename.absFilename());
docstring str;
+ // re-allocate master if necessary
+ if (is_child && theBufferList().isLoaded(master)
+ && buf->masterBuffer() != master)
+ buf->setParent(master);
if (buf) {
buf->updateLabels();
setBuffer(buf);