From 49fffba7d02d116bbfffb5244aa17df6c2cdcbd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Andr=C3=A9=20Tanner?= Date: Fri, 12 Feb 2016 19:29:18 +0100 Subject: [PATCH] vis: remove trailing new line before executing prompt command This should actually make the search history functionality work. The :-commands already worked because of commit e745b5ef. Removing all trailing white spaces would be the wrong thing to do for the search, because they might be part of the desired search string. --- vis-prompt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/vis-prompt.c b/vis-prompt.c index ecb07b311..42b1a2c21 100644 --- a/vis-prompt.c +++ b/vis-prompt.c @@ -70,6 +70,10 @@ static const char *prompt_enter(Vis *vis, const char *keys, const Arg *arg) { return keys; } + size_t len = strlen(cmd); + if (len > 0 && cmd[len-1] == '\n') + cmd[len-1] = '\0'; + bool lastline = (range.end == text_size(txt)); prompt_restore(prompt); @@ -77,7 +81,7 @@ static const char *prompt_enter(Vis *vis, const char *keys, const Arg *arg) { prompt_hide(prompt); if (!lastline) { text_delete(txt, range.start, text_range_size(&range)); - text_insert(txt, text_size(txt), cmd, strlen(cmd)); + text_appendf(txt, "%s\n", cmd); } } else { vis->win = prompt;