Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

console.lua: implement real-time fuzzy autocompletion #15364

Merged
merged 5 commits into from
Nov 23, 2024

Conversation

guidocella
Copy link
Contributor

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.

For example, set vo gn<Tab> will complete to gpu-next.
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.
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.
Copy link

github-actions bot commented Nov 23, 2024

Download the artifacts for this pull request:

Windows
macOS

Typing a command prefix crashes console because first_useful_token is
nil. This already happened before implementing autocompletion if you did
no-osd<Tab>, but autocompletion made it evident.
If you run a command without manually selecting a completion, select the
first one. e.g. set vo gn runs set vo gpu-next.
@kasper93 kasper93 merged commit 2f271a9 into mpv-player:master Nov 23, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants