Keep neoirc-cli responding when a key or a typed line updates the screen (closes #223)
check / check (push) Canceled after 0s
check / check (push) Canceled after 0s
The Enter handler of the input line and the Alt and digit key handler ran the typed line on the tview event loop. Every UI method that changes the screen waits for that loop, so the client stopped responding. Each line now runs on its own goroutine, which first waits for the line before it, so lines keep the order they were typed in. /window now runs off the event loop. It reads the buffer name through the new BufferName, which runs on the loop, and switches only when that buffer exists. One new test drives a running UI on a simulation screen with Alt and 1, then a typed line and Enter. Another holds the first line and checks that the second waits for it. Model: opus-5-5
This commit is contained in:
+10
-7
@@ -610,21 +610,24 @@ func (a *App) cmdWindow(args string) {
|
||||
|
||||
_, _ = fmt.Sscanf(args, "%d", &bufIndex)
|
||||
|
||||
a.ui.SwitchBuffer(bufIndex)
|
||||
|
||||
a.mu.Lock()
|
||||
nick := a.nick
|
||||
a.mu.Unlock()
|
||||
|
||||
if bufIndex >= 0 && bufIndex < a.ui.BufferCount() {
|
||||
buf := a.ui.buffers[bufIndex]
|
||||
if buf.Name != "(status)" {
|
||||
// Read the name before switching. A message from the server can
|
||||
// add a buffer at any time, but only at the end, so bufIndex
|
||||
// still names this buffer when SwitchBuffer runs.
|
||||
name, found := a.ui.BufferName(bufIndex)
|
||||
if found {
|
||||
a.ui.SwitchBuffer(bufIndex)
|
||||
|
||||
if name != "(status)" {
|
||||
a.mu.Lock()
|
||||
a.target = buf.Name
|
||||
a.target = name
|
||||
a.mu.Unlock()
|
||||
|
||||
a.ui.SetStatus(
|
||||
nick, buf.Name, "connected",
|
||||
nick, name, "connected",
|
||||
)
|
||||
} else {
|
||||
a.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user