There is a revert to file problem. It is not wise to check if it is
loading time for this though. I guess we can look at the status of the
existing file, if it has no changes, just switch to it.
What I meant was attached. I am not quite sure if the logic is
correct, otherwise, if should be used long ago. :-)
Bo
Index: src/BufferView_pimpl.C
===================================================================
--- src/BufferView_pimpl.C (revision 13781)
+++ src/BufferView_pimpl.C (working copy)
@@ -243,15 +243,18 @@
// File already open?
if (bufferlist.exists(s)) {
- string const file = makeDisplayPath(s, 20);
- string text = bformat(_("The document %1$s is already "
+ Buffer * existingBuf = bufferlist.getBuffer(s);
+ bool switchToBuf = existingBuf->isClean();
+ if (!switchToBuf) {
+ string const file = makeDisplayPath(s, 20);
+ string text = bformat(_("The document %1$s is already "
"loaded.\n\nDo you want to revert "
"to the saved version?"), file);
- int const ret = Alert::prompt(_("Revert to saved document?"),
- text, 0, 1, _("&Revert"), _("&Switch to document"));
-
- if (ret != 0) {
- setBuffer(bufferlist.getBuffer(s));
+ switchToBuf = 0 != Alert::prompt(_("Revert to saved document?"),
+ text, 0, 1, _("&Revert"), _("&Switch to document"));
+ }
+ if (switchToBuf) {
+ setBuffer(existingBuf);
return true;
}
// FIXME: should be LFUN_REVERT