opencode
opencode copied to clipboard
fix: add LRU eviction to LSP client file and diagnostics tracking
Fixes #3013
Summary
- Add LRU eviction to LSP client file and diagnostics tracking maps
- Create reusable
LRUMaputility class with configurable max size
Problem
The LSP client tracks files and diagnostics in unbounded Maps. In large codebases or long sessions, these maps grow without limit, contributing to memory pressure.
Solution
Replace plain Map with LRUMap that automatically evicts least-recently-used entries when a maximum size is exceeded. Default limits:
- Files: 1000 entries
- Diagnostics: 500 entries
Testing
Added tests for LRUMap utility. LSP functionality preserved.