Optimize `jj log` generation via async execution and caching
did:plc:2aeioyq3tv4brcuypgqqzobm wants to merge
did:plc:2aeioyq3tv4brcuypgqqzobm opened 27d ago
This PR significantly improves the performance of jj-log.nvim by reducing synchronous blocking operations and optimizing how often the jj log subprocess is spawned.
## Key Optimizations
* Replaced synchronous file I/O checks: Swapped the blocking vim.fn.filereadable() with a quick check on the buffer type (vim.bo.buftype).
The plugin now naturally ignores unbacked buffers (terminals, help files, etc.) without hitting the disk.
* Directory Caching: Refactored .jj repository detection into a new helpers.lua module. The upward directory traversal now utilizes
non-blocking vim.uv.fs_stat and caches all intermediate directories.
* Subprocess Debouncing: Implemented a per-repository lock to prevent the plugin from spawning overlapping jj log shell commands if
multiple autocommands fire concurrently.
* Command Output Caching: Added a description cache (cache_timeout_ms, defaulting to 2 seconds). Subsequent buffer events within this
window will immediately return the cached string rather than spinning up a new shell process.
* Synchronized Split/Tab Updates: When the async jj log command finishes, the plugin now updates vim.b.jj_desc for all valid open buffers
belonging to that repository simultaneously, ensuring status lines stay perfectly in sync.
* Graceful Failures: Wrapped Neovim API calls in pcall() so the plugin fails safely if a buffer is closed before the async shell command
completes.
Comments (0)
No comments yet.