reedline icon indicating copy to clipboard operation
reedline copied to clipboard

Unnecessary completion request when updating the common prefix to the command line.

Open blindFS opened this issue 2 months ago • 3 comments

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
}

  1. foo <tab> returns those 2 items with the common prefix "
  2. Reedline updates the line text to foo "
  3. 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.

blindFS avatar Oct 15 '25 10:10 blindFS

This probably isn't something we want to do right now, but in the future, we should offer a convenient way to cache results.

ysthakur avatar Oct 15 '25 11:10 ysthakur

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.

blindFS avatar Oct 15 '25 14:10 blindFS

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

blindFS avatar Oct 26 '25 05:10 blindFS