Ticket #4292: fix redundant back slashes for autocomplete.

Steps to reproduce:

1. Create file owth a space in the name:
  touch "a b"
There should no other files with name begins with "a" in the directory.
2. Press Shift-F4 to open editor
3. Press Shift-F2 to display dialog window "Save as..."
4. Press Esc+Tab to fill an input line

Result:
a\ b will appear in the edit field.
If you attempt to save the file, the back slash will be in the filename.

Expected result:
no any extra back slashes in the file name.

Soution: escape only '?', '*', and '&' symbols as described in the
manual page (see a11995e12b).

Signed-off-by: Andrew Borodin <aborodin@vmail.ru>
This commit is contained in:
Andrew Borodin 2024-04-30 16:12:40 +03:00
parent 49e2535c07
commit 2ee620f74f

View File

@ -1367,9 +1367,8 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
g_free (state.word);
if (matches != NULL &&
(flags & (INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_SHELL_ESC)) !=
(INPUT_COMPLETE_FILENAMES | INPUT_COMPLETE_SHELL_ESC))
if (matches != NULL && (flags & INPUT_COMPLETE_FILENAMES) != 0 &&
(flags & INPUT_COMPLETE_SHELL_ESC) == 0)
{
/* FIXME: HACK? INPUT_COMPLETE_SHELL_ESC is used only in command line. */
char **m;
@ -1379,7 +1378,9 @@ try_complete (char *text, int *lc_start, int *lc_end, input_complete_t flags)
char *p;
p = *m;
*m = str_shell_escape (*m);
/* Escape only '?', '*', and '&' symbols as described in the
manual page (see a11995e12b88285e044f644904c306ed6c342ad0). */
*m = str_escape (*m, -1, "?*&", TRUE);
g_free (p);
}
}