Skip to content

Allow custom/external completers to override display value - #17330

Merged
ysthakur merged 3 commits into
nushell:mainfrom
ysthakur:display-override
Jan 24, 2026
Merged

ysthakur merged 3 commits into
nushell:mainfrom
ysthakur:display-override

Conversation

@ysthakur

@ysthakur ysthakur commented Jan 11, 2026 •

Copy link
Copy Markdown
Member

Make Nushell compile after nushell/reedline#1002 and allow custom/external completers to override display value.

This adds a new display_override field to the suggestion record that completers can return.

Release notes summary - What our users need to know

Custom and external completers will now be able to set a display value for their suggestions that's separate from the value that will be filled into the buffer. They can do this by creating suggestions with the display_override field set. The display_override field is allowed to contain ANSI escapes for styling suggestions more extensively than the style field allows.

def completer [] {
  [{
    value: "foobarbaz",
    display_override: $"(ansi red)foo(ansi green)bar(ansi blue)baz"
  }]
}

Tasks after submitting

impl NuMatcher<'_, SemanticSuggestion> {
pub fn add_semantic_suggestion(&mut self, sugg: SemanticSuggestion) -> bool {
let value = sugg.suggestion.value.to_string();
let value = sugg.suggestion.display_value().to_string();

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change currently doesn't do anything, but in the future, we'll start setting display_override. At that point, I think using the display value will be more sensible than using value (especially since the match_indices would have to apply to the displayed value).

@fdncred

fdncred commented Jan 11, 2026 •

Copy link
Copy Markdown
Contributor

I noticed in this example

 $"(ansi red)foo(ansi green)bar(ansi blue)baz"

there is no (ansi reset) at the end. Does that happen in the reedline PR somewhere? We don't want ansi bleed.

@ysthakur

Copy link
Copy Markdown
Member Author

Yeah, nothing to worry about. We already add a reset after the value in both the columnar menu and the IDE menu (since before this display override stuff). This is what the example above looks like if you have several of the suggestions:

image

@ysthakur
ysthakur marked this pull request as ready for review January 24, 2026 19:05
@ysthakur
ysthakur merged commit 8c1790f into nushell:main Jan 24, 2026
17 checks passed
@ysthakur
ysthakur deleted the display-override branch January 24, 2026 19:05
@github-actions github-actions Bot added this to the v0.111.0 milestone Jan 24, 2026
@cptpiepmatz cptpiepmatz added notes:ready Indicates Ready for Release notes notes:additions Noted in "Additions" section labels Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:additions Noted in "Additions" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants