Skip to content

commands.lua: add quotes to file completion - #18336

Open
guidocella wants to merge 1 commit into
mpv-player:masterfrom
guidocella:quote-files
Open

commands.lua: add quotes to file completion#18336
guidocella wants to merge 1 commit into
mpv-player:masterfrom
guidocella:quote-files

Conversation

@guidocella

Copy link
Copy Markdown
Contributor

Automatically inserting quotes in file completion problematic, because when completing directories you want the cursor before the final quote rather than after in order to further complete the files within, and there is no system to set a cursor position before the end of the completion.

However we can add quotes automatically without this issue when:

  • completing files in the current directory
  • we can add only the first quote when completing directories in the current directory
  • we can add the final quote after files if the user typed a quote at the beginning of the path, since there's nothing remaining to complete after regular files

This adds single quotes because they are easier to type. Filenames containing both spaces and single quotes are not supported.

Automatically inserting quotes in file completion problematic, because
when completing directories you want the cursor before the final quote
rather than after in order to further complete the files within, and
there is no system to set a cursor position before the end of the
completion.

However we can add quotes automatically without this issue when:
- completing files in the current directory
- we can add only the first quote when completing directories in the
  current directory
- we can add the final quote after files if the user typed a quote at
  the beginning of the path, since there's nothing remaining to complete
  after regular files

This adds single quotes because they are easier to type. Filenames
containing both spaces and single quotes are not supported.
@na-na-hi

na-na-hi commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

The quote issue can be avoided entirely by auto escaping special characters instead. There won't be quote character at the end that interferes further completion this way.

@guidocella

Copy link
Copy Markdown
Contributor Author

How? mpv interprets foo\ bar as 2 arguments.

@na-na-hi

na-na-hi commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Console can preprocess the input and make that one argument. Similar to what shells do.

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