Prevent crash when attempting to restore a file multiple times.

We currently cannot restore multiple views of the same buffer properly.
On the mac, we even crash.
So do not try it, record each file only once in the last opened list.

Fixes: #9483.
This commit is contained in:
Juergen Spitzmueller 2015-04-06 09:55:07 +02:00
parent 29705851cb
commit c46162db23

View File

@ -150,6 +150,16 @@ void LastOpenedSection::write(ostream & os) const
void LastOpenedSection::add(FileName const & file, bool active)
{
LastOpenedFile lof(file, active);
// check if file is already recorded (this can happen
// with multiple buffer views). We do only record each
// file once, since we cannot restore multiple views
// currently, we even crash in some cases (see #9483).
// FIXME: Add session support for multiple views of
// the same buffer (split-view etc.).
for (size_t i = 0; i < lastopened.size(); ++i) {
if (lastopened[i].file_name == file)
return;
}
lastopened.push_back(lof);
}