summaryrefslogtreecommitdiff
path: root/src/buffer_utils.cc
diff options
context:
space:
mode:
authorJohannes Altmanninger <aclopte@gmail.com>2024-12-13 08:24:22 +0100
committerMaxime Coste <mawww@kakoune.org>2025-06-26 11:34:17 +1000
commitcff5f12a852a34a548aabfb6166c86fa35466a83 (patch)
tree99ab74642a06182f74db10305512b227d3625429 /src/buffer_utils.cc
parent096d72bbb11e3a2ec227de9eda4dfac02ed970aa (diff)
Fix flaky blame-in-diff test and "edit -fifo" in BufCloseFifo
This test uses ui_out and ui_in to coordinate events. This is brittle[1] because ui_out behavior depends on timing. Since this test doesn't really care about intermediate UI state, express the sequence using BufCloseFifo instead. This hits another issue: inside git blame-jump's BufCloseFifo, we run git blame, which runs another "edit -fifo .. *git*". A special aspect of fifo buffers is that any existing *git* buffer will be reused instead of being recreated[2]. After BufCloseFifo, the fifo watcher destructor will reset the fifo flag, even if BufCloseFifo has recreated the fifo buffer. This breaks invariants and causes the next fifo watcher destructor do fail its assertion. Let's not reset fifo flags in this case. This should be safe because it's the very last thing the fifo watcher does, so it's okay if another one is active now. Alternatively we could reject this kind of recursion, or implement it in a different way (using ScopedSetBool for the flags). Reported-by: Nico Sonack <nsonack@herrhotzenplotz.de> [1]: https://lists.sr.ht/~mawww/kakoune/%3C20241210100417.1150697-1-aclopte@gmail.com%3E [2]: This removes the need to use delete-buffer which also ensures that the buffer remains visible in any client it's already shown.
Diffstat (limited to 'src/buffer_utils.cc')
-rw-r--r--src/buffer_utils.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/buffer_utils.cc b/src/buffer_utils.cc
index a2d2e709..bb64e9c1 100644
--- a/src/buffer_utils.cc
+++ b/src/buffer_utils.cc
@@ -290,7 +290,8 @@ Buffer* create_fifo_buffer(String name, int fd, Buffer::Flags flags, AutoScroll
kak_assert(m_buffer.flags() & Buffer::Flags::Fifo);
close_fd();
m_buffer.run_hook_in_own_context(Hook::BufCloseFifo, "");
- m_buffer.flags() &= ~(Buffer::Flags::Fifo | Buffer::Flags::NoUndo);
+ if (not m_buffer.values().contains(fifo_watcher_id))
+ m_buffer.flags() &= ~(Buffer::Flags::Fifo | Buffer::Flags::NoUndo);
}
void read_fifo()