fix(menu): Don't apply selected_text style to matched text in suggestions #994
+26
−5
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.
#798 broke completion menu highlighting, which included making it so that the
selected_textstyle was applied to matched text. #991 tried fixing #798 but missed the matched text problem. This PR makes it so that matched text only has thetextandmatch/selected_matchstyles applied to it.This is just a temporary fix. This works for now because suggestion values can't contain ANSI escapes, but once we start allowing suggestions to provide a separate display value with ANSI escapes, we need to handle the Reset attribute (0). It would also be good to handle consecutive ANSI escapes, but that one's not necessary.
Testing
Here's what Nushell looks like after this PR:
Nushell config:
{ name: completion_menu only_buffer_difference: false marker: $" \n❯ (char -u '1f4ce') " type: { layout: columnar columns: 4 col_width: 20 # Optional value. If missing all the screen width is used to calculate column width col_padding: 2 tab_traversal: "vertical" # Direction in which pressing <Tab> will cycle through options, "horizontal" or "vertical" } style: { text: { fg: "#33ff00" } selected_text: {attr: r} description_text: yellow match_text: {attr: u} selected_match_text: {fg: darkorange attr: b} } }