xP/xW: fix buffer rename handling

Maintaining string pointers to the current/last buffer
means that renames invalidate them.
This commit is contained in:
Přemysl Eric Janouch 2023-08-25 21:20:50 +02:00
parent c22dd67fc1
commit 34521e61c1
Signed by: p
GPG Key ID: A0420B94F92B9493
2 changed files with 11 additions and 2 deletions

View File

@ -344,6 +344,11 @@ rpcEventHandlers.set(Relay.Event.BufferStats, e => {
rpcEventHandlers.set(Relay.Event.BufferRename, e => {
buffers.set(e.new, buffers.get(e.bufferName))
buffers.delete(e.bufferName)
if (e.bufferName === bufferCurrent)
bufferCurrent = e.new
if (e.bufferName === bufferLast)
bufferLast = e.new
})
rpcEventHandlers.set(Relay.Event.BufferRemove, e => {

View File

@ -914,11 +914,15 @@ relay_process_message(const Relay::EventMessage &m)
if (!b)
break;
b->buffer_name = data.buffer_name;
b->buffer_name = data.new_;
refresh_buffer_list();
if (b->buffer_name == g.buffer_current)
if (data.buffer_name == g.buffer_current) {
g.buffer_current = data.new_;
refresh_status();
}
if (data.buffer_name == g.buffer_last)
g.buffer_last = data.new_;
break;
}
case Relay::Event::BUFFER_REMOVE: