console.lua: implement real-time fuzzy autocompletion #15364
Merged
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.
console.lua: determine completions with fuzzy search
For example, set vo gn will complete to gpu-next.
console.lua: complete fewer properties
10k properties makes the console hang and the CPU fan spin with live fuzzy filtering, so print fewer sub-properties. These are rarely useful anyway.
console.lua: show completions as you type
Show available completion suggestions as you type without having to press Tab.
This is fast even on a 2011 CPU, so we can get away with doing this in the same thread that draws the console. The one case where it could make the console hang is file completion of network drives, but in general it is convenient for loadfile.
mp.input.get clients also get a request to complete on each character typed, but those run in a different thread so performance is always fine, and completions were already rejected if the input line or cursor changed after the request. If I ever make running mpv commands an mp.input client in the future, command completion will also benefit from running in a different thread.