GNOME Bugzilla – Bug 767369
command-bar: Fix a bug in tab autocompletion
Last modified: 2016-06-11 13:25:10 UTC
In the command bar, if you try to tab autocomplete, it will show invalid characters sometimes.
Created attachment 329319 [details] [review] command-bar: Fix a file path tab autocomplete issue gb_command_bar_complete expects completions returned by the GbCommandVimProvider to include the full prefix that the user typed in, not just the filename. Since gb_vim_complete_edit_files returns the filename or a relative path from the working directory, gb_command_bar_complete reads past the end of a character array. This commit makes the completion provider return full file paths to fix this issue.
Created attachment 329320 [details] [review] command-bar: Check if the completion provider fulfills its contract Emit a warning if the provided completion is not a prefix of the command typed by the user, and don't display it as an option. Otherwise we would read past the end of a character array.
Review of attachment 329319 [details] [review]: Looks good, just add the = NULL to the autofree then feel free to push/close. ::: plugins/command-bar/gb-vim.c @@ +1325,3 @@ + gchar *completed_command; + const gchar *descendent_name; + g_autofree gchar *full_path; Always set g_autofree declarations to NULL, even if they get set immediately after declaration. (We just like to be consistent everywhere so it is easy to catch improper use).
Created attachment 329324 [details] [review] command-bar: Fix a file path tab autocomplete issue gb_command_bar_complete expects completions returned by the GbCommandVimProvider to include the full prefix that the user typed in, not just the filename. Since gb_vim_complete_edit_files returns the filename or a relative path from the working directory, gb_command_bar_complete reads past the end of a character array. This commit makes the completion provider return full file paths to fix this issue.
Created attachment 329325 [details] [review] command-bar: Check if the completion provider fulfills its contract Emit a warning if the provided completion is not a prefix of the command typed by the user, and don't display it as an option. Otherwise we would read past the end of a character array.
Review of attachment 329325 [details] [review]: LGTM
Review of attachment 329324 [details] [review]: LGTM
The following fixes have been pushed: f927694 command-bar: Check if the completion provider fulfills its contract 08cc0c1 command-bar: Fix a file path tab autocomplete issue
Created attachment 329489 [details] [review] command-bar: Check if the completion provider fulfills its contract Emit a warning if the provided completion is not a prefix of the command typed by the user, and don't display it as an option. Otherwise we would read past the end of a character array.
Created attachment 329490 [details] [review] command-bar: Check if the completion provider fulfills its contract Emit a warning if the provided completion is not a prefix of the command typed by the user, and don't display it as an option. Otherwise we would read past the end of a character array.
Created attachment 329491 [details] [review] command-bar: Fix a file path tab autocomplete issue gb_command_bar_complete expects completions returned by the GbCommandVimProvider to include the full prefix that the user typed in, not just the filename. Since gb_vim_complete_edit_files returns the filename or a relative path from the working directory, gb_command_bar_complete reads past the end of a character array. This commit makes the completion provider return full file paths to fix this issue.
Created attachment 329585 [details] [review] command-bar: Fix vim mode tab autocompletion issues gb_vim_complete_edit_files returns the completed file path as an absolute path even when the user typed a relative path. This commit makes the completion look like the user input even for relative paths, which allows gb_command_bar_complete to correctly complete file paths for the user.
Review of attachment 329585 [details] [review]: ::: plugins/command-bar/gb-vim.c @@ +1308,3 @@ + { + partial_name = slash + 1; + prefix_dir = g_strndup (prefix, slash - prefix + 1); Leaking prefix_dir here.
Created attachment 329589 [details] [review] command-bar: Fix vim mode tab autocompletion issues gb_vim_complete_edit_files returns the completed file path as an absolute path even when the user typed a relative path. This commit makes the completion look like the user input even for relative paths, which allows gb_command_bar_complete to correctly complete file paths for the user.
Review of attachment 329589 [details] [review]: ::: plugins/command-bar/gb-vim.c @@ +1296,3 @@ const gchar *slash; + const gchar *partial_name; + g_autofree const gchar *prefix_dir; = NULL and drop the const
Created attachment 329593 [details] [review] command-bar: Fix vim mode tab autocompletion issues gb_vim_complete_edit_files returns the completed file path as an absolute path even when the user typed a relative path. This commit makes the completion look like the user input even for relative paths, which allows gb_command_bar_complete to correctly complete file paths for the user.
Review of attachment 329593 [details] [review]: LGTM
Attachment 329593 [details] pushed as 83116ae - command-bar: Fix vim mode tab autocompletion issues