>> I don't know how severe are the consequences. The only side-effect I noticed >> that prev-buffers of restored windows are the same on different tabs because >> they share the same window. > > If that is a problem and the above would help, let's do it. It couldn't > possibly harm unless the root window is too small to get split and we > want to put only one window there; so we should handle that special case. The original problem was that prev-buffers of restored windows are the same on different tabs. This was fixed by always creating a new window. However, the same problem still exists, but for a different reason. Most windows have current buffer duplicated in prev-buffers. So when set-window-prev-buffers in window--state-put-2 sets prev-buffers to a list with only current buffer, this means as if there are no prev-buffers. But when a window has an empty list of prev-buffers, then the window parameter of prev-buffers is not cleared, and still contains a random buffer from some previous state. This patch fixes it: