Perf issue: scrolling in the completion menu keeps triggering (re)parsing of the command line over and over
Platform macOS Terminal software ghostty
Found this issue during https://github.com/nushell/nushell/pull/15270
Steps to reproduce
- type in
use std <tab> - hold ctrl-p/ctrl-n down for a while
rustc optimized nu release performs noticeably better.
Basically the menu next/prev event will trigger the parsing of the cli, which involves dozens of parse_module_file calls.
I guess it has something to do with the highlighting. But since the cli text doesn't change by those events (maybe I missed some config here to make it happen), I think it should be optimized.
Typing in cli after use std is also not very responsive due to the same reason, but that is probably harder to fix.
Nice catch. Would be wonderful to figure out how to fix this.
Ideally, highlighting better to be an async function and then we can set a debounce timeout for it.
I'm not sure if it worth the effort, since the only remaining situation that I can notice the lagging (but I only tested it on M4 pro chip) is use std <typing/left/right>. And that one seems to me a nu_parser issue.
i would love to see some asyn in reedline to fix things like this and be a bit more powerful