about summary refs log tree commit diff stats
path: root/src/local/client.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-03-03 17:33:09 +0100
committerbptato <nincsnevem662@gmail.com>2024-03-03 17:33:09 +0100
commitb4a0b79cacefdb58d556aec8ee75d6f1f7a0be49 (patch)
tree5cdf6dfafcb6ad90e64b5ad2f4f44b0ef7178ead /src/local/client.nim
parent6776f4dba975137f4034b1295c0f1958b752a2cb (diff)
downloadchawan-b4a0b79cacefdb58d556aec8ee75d6f1f7a0be49.tar.gz
buffer: improve/fix onload return values
Only report when bytesRead has changed, otherwise we get unnecessary
load requests. (This means -2 return value no longer exists; it did
not work correctly anyway.)

Also, fix the race condition that broke onload returns when onload
happened before client requested load.
Diffstat (limited to 'src/local/client.nim')
-rw-r--r--src/local/client.nim9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/local/client.nim b/src/local/client.nim
index baea712f..7821eb23 100644
--- a/src/local/client.nim
+++ b/src/local/client.nim
@@ -432,7 +432,6 @@ proc showConsole(client: Client) {.jsfunc.} =
   if client.pager.container != container:
     client.consoleWrapper.prev = client.pager.container
     client.pager.setContainer(container)
-    container.requestLines()
 
 proc hideConsole(client: Client) {.jsfunc.} =
   if client.pager.container == client.consoleWrapper.container:
@@ -582,8 +581,9 @@ proc inputLoop(client: Client) =
       if selectors.Event.Timer in event.events:
         let r = client.timeouts.runTimeoutFd(event.fd)
         assert r
-        client.pager.container.requestLines().then(proc() =
-          client.pager.container.cursorLastLine())
+        let container = client.consoleWrapper.container
+        if container != nil:
+          container.tailOnLoad = true
     client.runJSJobs()
     client.loader.unregistered.setLen(0)
     client.acceptBuffers()
@@ -671,10 +671,9 @@ proc addConsole(pager: Pager, interactive: bool, clearFun, showFun, hideFun:
     let url = newURL("stream:console").get
     let container = pager.readPipe0("text/plain", CHARSET_UNKNOWN, pipefd[0],
       some(url), ConsoleTitle, canreinterpret = false)
+    pager.registerContainer(container)
     let err = newPosixStream(pipefd[1])
     err.writeLine("Type (M-c) console.hide() to return to buffer mode.")
-    err.flush()
-    pager.registerContainer(container)
     let console = newConsole(
       err,
       clearFun = clearFun,