[BUG][v0.0.7] model_picker.rs: fix legend overlap + UTF-8 caret misalignment#222
Open
sungdark wants to merge 1 commit intoCortexLM:mainfrom
Open
[BUG][v0.0.7] model_picker.rs: fix legend overlap + UTF-8 caret misalignment#222sungdark wants to merge 1 commit intoCortexLM:mainfrom
sungdark wants to merge 1 commit intoCortexLM:mainfrom
Conversation
Fix two bugs in cortex-tui model picker (issue #40176): A) Legend/help row overlap (narrow terminals): render_help_bar now checks that help_x > legend_right + 1 before rendering the shortcut string. When the terminal is too narrow the legend (* / +) renders alone — no garbled collision. B) Search caret uses byte length instead of display width: render_search_bar now uses UnicodeWidthStr::width() instead of .len() so CJK characters and emoji don't misplace the caret. Both fixes are conservative; existing behaviour is preserved when there is enough terminal space.
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
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.
Fix: model_picker narrow-terminal overlap and UTF-8 caret misalignment
Bug A — Legend / help row overlap
File:
src/cortex-tui/src/widgets/model_picker.rsFunction:
render_help_barhelp_x = area.right().saturating_sub(help.len() + 1)has no guard to stay to the right of the legend. For narrow terminals (50-60 cols) the shortcut string overwrites the legend, producing a garbled footer.Fix: Check that
help_x > legend_right + 1before rendering the help string. When width is insufficient only the legend (* / +) is shown — no overlap.Bug B — Search caret uses byte length instead of display width
File:
src/cortex-tui/src/widgets/model_picker.rsFunction:
render_search_barcursor_x = x + 3 + self.state.search_query.len()usesstr::len()which counts UTF-8 bytes. Multi-byte characters (CJK, emoji) cause the caret to misalign with the visible text.Fix: Use
UnicodeWidthStr::width()(already a workspace dependency) instead of byte length.Testing
Bounty
Issue: PlatformNetwork/bounty-challenge#40176