Unnecessary completion request when updating the common prefix to the command line.
From https://github.com/nushell/nushell/issues/16860, we can tell that there's something to optimize.
Steps to reproduce
def completion [] {
['"first item"' '"second item"']
}
export def foo [c: string@completion] {
print $c
}
foo <tab>returns those 2 items with the common prefix"- Reedline updates the line text to
foo " - During menu redraw (maybe?), the completion results are updated to those for the new text
foo ", which is totally unnecessary in theory.
It could potentially be a dealbreaker for time costing external completer.
This probably isn't something we want to do right now, but in the future, we should offer a convenient way to cache results.
This probably isn't something we want to do right now, but in the future, we should offer a convenient way to cache results.
Maybe unrelated, but this reminds me of #881.
I will try fixing that one first, hopefully it will make fixing this much easier.
TODO: this is the place (also in ide_menu.rs) to address this issue, we could easily recalculate the new spans according to the common prefix length instead of starting over the completion:
https://github.com/nushell/reedline/blob/22768f3e01523e3a2ea7d521f298909155a22496/src/menu/columnar_menu.rs#L515-L517