vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

commit f1d01cb8b6f7bcfccdd9b49fe9251761430a7cdd
parent 0154e8e7a2505f19a768bf390c2e707e37de12d3
Author: Marc André Tanner <mat@brain-dump.org>
Date:   Fri, 12 Feb 2016 19:29:18 +0100

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 d99c8253.
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.

Diffstat:
Mvis-prompt.c | 6+++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git 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;