diff options
| author | Marc André Tanner <mat@brain-dump.org> | 2016-02-12 19:29:18 +0100 |
|---|---|---|
| committer | Marc André Tanner <mat@brain-dump.org> | 2016-02-12 19:29:18 +0100 |
| commit | 49fffba7d02d116bbfffb5244aa17df6c2cdcbd2 (patch) | |
| tree | de0e00cba2bb74aeba20dab760d4f58f0609d854 /vis-prompt.c | |
| parent | e4fc2780f776db0a2134655247a080e48f77e05f (diff) | |
| download | vis-49fffba7d02d116bbfffb5244aa17df6c2cdcbd2.tar.gz vis-49fffba7d02d116bbfffb5244aa17df6c2cdcbd2.tar.xz | |
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.
Diffstat (limited to 'vis-prompt.c')
| -rw-r--r-- | vis-prompt.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/vis-prompt.c b/vis-prompt.c index ecb07b3..42b1a2c 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; |
