When BufferView::Pimpl::loadLyXFile is invoked to load a file that is already loaded, the user is asked whether he wants to just switch or re-load the file. The following patch(es) chnage the behavior so that, when the buffer is clean, the switch solution is automatically selected.
Does anyone object to that? JMarc
Index: src/BufferView_pimpl.C =================================================================== --- src/BufferView_pimpl.C (revision 13918) +++ src/BufferView_pimpl.C (working copy) @@ -250,8 +250,17 @@ bool BufferView::Pimpl::loadLyXFile(stri if (!found) s = filename; + Buffer * b = bufferlist.getBuffer(s); + // File already open? - if (bufferlist.exists(s)) { + if (b) { + // if buffer is already loaded and is clean, just + // bring it to front. + if (b->isClean()) { + setBuffer(b); + return true; + } + string const file = makeDisplayPath(s, 20); string text = bformat(_("The document %1$s is already " "loaded.\n\nDo you want to revert " @@ -260,17 +269,15 @@ bool BufferView::Pimpl::loadLyXFile(stri text, 0, 1, _("&Revert"), _("&Switch to document")); if (ret != 0) { - setBuffer(bufferlist.getBuffer(s)); + setBuffer(b); return true; } // FIXME: should be LFUN_REVERT - if (!bufferlist.close(bufferlist.getBuffer(s), false)) + if (!bufferlist.close(b, false)) return false; // Fall through to new load. (Asger) } - Buffer * b = 0; - if (found) { b = bufferlist.newBuffer(s); connectBuffer(*b);
Index: src/BufferView_pimpl.C =================================================================== --- src/BufferView_pimpl.C (revision 13918) +++ src/BufferView_pimpl.C (working copy) @@ -250,8 +250,17 @@ bool BufferView::Pimpl::loadLyXFile(stri if (!found) s = filename; + Buffer * b = bufferlist.getBuffer(s); + // File already open? - if (bufferlist.exists(s)) { + if (b) { + // if buffer is already loaded and is clean, just + // bring it to front. + if (b->isClean()) { + setBuffer(b); + return true; + } + string const file = MakeDisplayPath(s, 20); string text = bformat(_("The document %1$s is already " "loaded.\n\nDo you want to revert " @@ -260,17 +269,15 @@ bool BufferView::Pimpl::loadLyXFile(stri text, 0, 1, _("&Revert"), _("&Switch to document")); if (ret != 0) { - setBuffer(bufferlist.getBuffer(s)); + setBuffer(b); return true; } // FIXME: should be LFUN_REVERT - if (!bufferlist.close(bufferlist.getBuffer(s), false)) + if (!bufferlist.close(b, false)) return false; // Fall through to new load. (Asger) } - Buffer * b = 0; - if (found) { b = bufferlist.newBuffer(s); connectBuffer(*b);