diff options
| author | Ben Sima <ben@bsima.me> | 2025-11-14 15:52:28 -0500 |
|---|---|---|
| committer | Ben Sima <ben@bsima.me> | 2025-11-14 15:52:28 -0500 |
| commit | d3acbdec5c04f27d33d7b2023b544a640a611947 (patch) | |
| tree | 68b139c2a31990704b49353d3b9a375e8e8a8061 /Omni/Log/Concurrent.hs | |
| parent | 669dd3a1ab6c72d530c6480afa1ee54f2353c8a6 (diff) | |
Fix concurrent terminal update issues
- Remove [+] display from reserveLine (was causing mangled output
from concurrent writes) - Add [+] display in analyze function where
it's single-threaded - Simplify cleanup to just move cursor down
without clearing lines - This eliminates race conditions and terminal
clearing issues
Diffstat (limited to 'Omni/Log/Concurrent.hs')
| -rw-r--r-- | Omni/Log/Concurrent.hs | 20 |
1 files changed, 2 insertions, 18 deletions
diff --git a/Omni/Log/Concurrent.hs b/Omni/Log/Concurrent.hs index 391fcff..204e497 100644 --- a/Omni/Log/Concurrent.hs +++ b/Omni/Log/Concurrent.hs @@ -89,11 +89,7 @@ withLineManager maxLines action = do result <- action mgr - forM_ [0 .. maxLines - 1] <| \_ -> do - ANSI.hCursorDown IO.stderr 1 - ANSI.hSetCursorColumn IO.stderr 0 - ANSI.hClearLine IO.stderr - + ANSI.hCursorDown IO.stderr maxLines writeIORef currentLineManager Nothing writeIORef namespaceLines Map.empty pure result @@ -122,19 +118,7 @@ reserveLine LineManager {..} ns = linesMap' = Map.insert lineNum (Just status) linesMap in (linesMap', Just lineNum) case mLine of - Just lineNum -> do - modifyIORef' namespaceLines (Map.insert ns lineNum) - currentLine <- readIORef lmCurrentLine - ANSI.hSaveCursor IO.stderr - ANSI.hSetCursorColumn IO.stderr 0 - let linesToMove = currentLine - lineNum - when (linesToMove > 0) <| ANSI.hCursorUp IO.stderr linesToMove - when (linesToMove < 0) <| ANSI.hCursorDown IO.stderr (abs linesToMove) - ANSI.hClearLine IO.stderr - let nsText = Text.pack (Namespace.toPath ns) - IO.hPutStr IO.stderr (Text.unpack <| "[+] " <> nsText) - IO.hFlush IO.stderr - ANSI.hRestoreCursor IO.stderr + Just lineNum -> modifyIORef' namespaceLines (Map.insert ns lineNum) Nothing -> pure () pure mLine where |
