Do not kill the undo stack when doing a Save As...

The code does a reload on the buffer to avoid loose pointers if the
file changes directory. This commit adds a bool parameter to
Buffer::reload to allow for keeping the undo stack intact. This is of
couse only wanted in this case, not when reloading an earlier version
of the file.
This commit is contained in:
Jean-Marc Lasgouttes 2012-07-18 10:31:47 +02:00
parent 6ec1683aee
commit 467422f9df
3 changed files with 6 additions and 4 deletions

View File

@ -4580,7 +4580,7 @@ int Buffer::charCount(bool with_blanks) const
}
Buffer::ReadStatus Buffer::reload()
Buffer::ReadStatus Buffer::reload(bool clearUndo)
{
setBusy(true);
// c.f. bug http://www.lyx.org/trac/ticket/6587
@ -4598,6 +4598,7 @@ Buffer::ReadStatus Buffer::reload()
updateTitles();
markClean();
message(bformat(_("Document %1$s reloaded."), disp_fn));
if (clearUndo)
d->undo_.clear();
} else {
message(bformat(_("Could not reload document %1$s."), disp_fn));

View File

@ -225,7 +225,8 @@ public:
/// read a new document from a string
bool readString(std::string const &);
/// Reloads the LyX file
ReadStatus reload();
/// \param clearUndo if false, leave alone the undo stack.
ReadStatus reload(bool clearUndo = true);
//FIXME: The following function should be private
//private:
/// read the header, returns number of unknown tokens

View File

@ -2320,7 +2320,7 @@ bool GuiView::renameBuffer(Buffer & b, docstring const & newname)
bool const saved = saveBuffer(b, fname);
if (saved)
b.reload();
b.reload(false);
return saved;
}