From ee218313a2d3f1c41f30102ba5498471b32925c0 Mon Sep 17 00:00:00 2001
From: Daniel Carl <danielcarl@gmx.de>
Date: Thu, 27 Apr 2017 22:08:17 +0200
Subject: [PATCH] Keep all content before command on completion.

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 | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/ex.c b/src/ex.c
index 6ce1ecb..6a64191 100644
--- 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;
             }
         }
-- 
2.20.1