Keep all content before command on completion.
authorDaniel Carl <danielcarl@gmx.de>
Thu, 27 Apr 2017 20:08:17 +0000 (22:08 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Thu, 27 Apr 2017 20:13:07 +0000 (22:13 +0200)
If ':: o' was completed, the white space and ':' before the command
where skipped and the user input was changed into ':open'. Vim keeps the
input also during command completion, so we follow this model and keep
it too.

src/ex.c

index 6ce1ecb..6a64191 100644 (file)
--- a/src/ex.c
+++ b/src/ex.c
@@ -801,7 +801,7 @@ static void on_eval_script_finished(GDBusProxy *proxy, GAsyncResult *result, Cli
     gboolean success = FALSE;
     char *string = NULL;
 
-    GVariant *return_value = g_dbus_proxy_call_finish(proxy, result, NULL);   
+    GVariant *return_value = g_dbus_proxy_call_finish(proxy, result, NULL);
     if (return_value) {
         g_variant_get(return_value, "(bs)", &success, &string);
         if (success) {
@@ -1139,7 +1139,7 @@ static gboolean complete(Client *c, short direction)
         parse_count(&in, arg);
 
         /* Backup the current pointer so that we can restore the input pointer
-         * if tha command name parsing fails. */
+         * if the command name parsing fails. */
         before_cmdname = in;
 
         /* Do ex command specific completion if the comman is recognized and
@@ -1215,7 +1215,8 @@ static gboolean complete(Client *c, short direction)
             excomp.count = arg->count;
 
             if (ex_fill_completion(store, in)) {
-                OVERWRITE_STRING(excomp.prefix, ":");
+                /* Use all the input before the command as prefix. */
+                OVERWRITE_NSTRING(excomp.prefix, input, in - input);
                 found = TRUE;
             }
         }