-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix handling of fragmented terminal background color responses #272
Conversation
- Refactor `incompleteResponse` to directly store buffered data - Simplify color validation to use `*Color` and `bool` exclusively - Remove embedded anonymous function for clarity
Thank you for the thorough review! I've implemented your suggested changes: Additional Corrections: During finally manual testing, I realized my initial reports omitted some key details: Windows Terminal, Zsh, WSL Ubuntu 24.04 not always reporing "background color detected" when moar didn't enter search mode at first. After the fix, moar still sometimes complains that it didn't detect terminal background color though it no longer enter search mode at the beginning. I turned my terminal scheme to Gruvbox Light to make it more clear: And the trace infomation is as follow:
Writting "Terminal background color still not detected after 50.237805ms, giving up". However it sometimes does get terminal background color, while the WT, PowerShell, Windows environment always does:
This issue seems to exist before this PR so I have no ideas about it. Should this problem be included in this PR too or report it in a new issue? Please let me know if further adjustments are needed. Your expertise knowledge is invaluable! |
This looks like the second half of an actual response. Maybe this would get more obvious with logging of incomplete-but-valid prefixes?
|
Hi @walles, Acknowledgement & Correction: Upon re-verification, I realized my earlier report about issues reproduction was based on outdated build artifacts (my local build cache wasn't properly cleaned). After rebuilding, All cases now handle background queries correctly. Trace information now:
This confirms the issue is fully resolved in the current implementation. My apologies for the earlier inaccurate context – appreciate your patience as I navigate these toolchain nuances. The PR remains ready for final review when convenient. |
Thanks for the suggestion! When implementing your feedback, I encountered a CI linting issue:
To resolve this, there are two options: Option 1: Keep original implementation }
// Not valid
incompleteResponse = nil
- expectingTerminalBackgroundColor = false
} (This is the currently committed version) Option 2: Remove assignment outside - // We only expect this on entry, it's requested right before we start
- // the main loop in NewScreenWithMouseModeAndColorCount().
- expectingTerminalBackgroundColor = false I temporarily chose Option 1 to keep CI passing, but happy to implement Option 2 if you prefer that approach. Please advise which direction you'd like me to pursue. All tests passed locally now:
|
Hi @walles 👋 Just a quick ping that this PR is now: The change remains small and low-risk. Would you like me to add any additional test cases or apply new suggestions? Happy to make final tweaks if needed! Appreciate your time reviewing this. |
Thanks @pilgrimlyieu, now released: |
Just verified v1.31.4 works perfectly now. Thanks for maintaining this brilliant tool! |
This PR resolves #271.
Key Changes:
incompleteResponse
buffer to accumulate partial escape sequences+ var incompleteResponse []byte
parseTerminalBgColorResponse()
to return completion status:Verification:
Tested with Gruvbox Dark some shcemes, no accidental search mode activation observed:
This fix resolves my immediate issue but would benefit from maintainer review. Happy to adjust based on feedback.