fix(input): cap console history growth (B3)#42
Open
Vadim1987 wants to merge 2 commits into
Open
Conversation
Collaborator
Owner
|
My opinion is, short of a compiler, static checks and tests are the only thing standing between us and pervasive bugs. And we still get bugs. |
Collaborator
|
@aldum do you approve this PR, then? |
Owner
|
@dsent Not as such, no. I'd like to see a config option, at least in-code. |
Author
|
Done: the limit is a constructor parameter fed from the config ("input_history" in baseconf, in-code as suggested), 0 means unlimited, default raised to 1000. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Console history grows for the whole session:
History:rememberonly ever appends, and nothing evicts, so on a long session every entered command accumulates in memory (each entry is a string[] of lines).The fix caps history at 100 entries: after an append,
_trimevicts from the front while over the limit. Since the backing store is a plain array, eviction shifts indices, so_trimalso shiftsself.indexwhen arrow-key navigation is active — the position keeps pointing at the same entry — and resets it if the navigated-to entry itself was evicted.The limit is a named constant; 100 entries comfortably covers a session on the device while keeping the worst case bounded.