Skip to content

Commit

Permalink
vis: remove trailing new line before executing prompt command
Browse files Browse the repository at this point in the history
This should actually make the search history functionality work.

The :-commands already worked because of commit e745b5e.
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.
  • Loading branch information
martanne committed Feb 12, 2016
1 parent e4fc278 commit 49fffba
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vis-prompt.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,18 @@ 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);
if (vis_prompt_cmd(vis, cmd)) {
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;
Expand Down

0 comments on commit 49fffba

Please sign in to comment.