vi: enable 'dG' command. Closes 11801
The 'G' command was omitted from the list of commands that change or delete whole lines. Add it in the appropriate places so the 'dG', 'cG' and 'yG' commands work, including in cases where an explicit line number has been supplied. function old new delta find_range 534 596 +62 .rodata 175166 175167 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 2/0 up/down: 63/0) Total: 63 bytes Reported-by: David Kelly <david.kelly@liberica.ch> Signed-off-by: Ron Yorston <rmy@pobox.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
parent
4b49422a08
commit
7b93e317c1
11
editors/vi.c
11
editors/vi.c
@ -3001,11 +3001,14 @@ static void do_cmd(int c);
|
|||||||
static int find_range(char **start, char **stop, char c)
|
static int find_range(char **start, char **stop, char c)
|
||||||
{
|
{
|
||||||
char *save_dot, *p, *q, *t;
|
char *save_dot, *p, *q, *t;
|
||||||
int cnt, multiline = 0;
|
int cnt, multiline = 0, forward;
|
||||||
|
|
||||||
save_dot = dot;
|
save_dot = dot;
|
||||||
p = q = dot;
|
p = q = dot;
|
||||||
|
|
||||||
|
// will a 'G' command move forwards or backwards?
|
||||||
|
forward = cmdcnt == 0 || cmdcnt > count_lines(text, dot);
|
||||||
|
|
||||||
if (strchr("cdy><", c)) {
|
if (strchr("cdy><", c)) {
|
||||||
// these cmds operate on whole lines
|
// these cmds operate on whole lines
|
||||||
p = q = begin_line(p);
|
p = q = begin_line(p);
|
||||||
@ -3029,13 +3032,13 @@ static int find_range(char **start, char **stop, char c)
|
|||||||
if (dot > text && *dot == '\n')
|
if (dot > text && *dot == '\n')
|
||||||
dot--; // stay off NL
|
dot--; // stay off NL
|
||||||
q = dot;
|
q = dot;
|
||||||
} else if (strchr("H-k{", c)) {
|
} else if (strchr("H-k{", c) || (c == 'G' && !forward)) {
|
||||||
// these operate on multi-lines backwards
|
// these operate on multi-lines backwards
|
||||||
q = end_line(dot); // find NL
|
q = end_line(dot); // find NL
|
||||||
do_cmd(c); // execute movement cmd
|
do_cmd(c); // execute movement cmd
|
||||||
dot_begin();
|
dot_begin();
|
||||||
p = dot;
|
p = dot;
|
||||||
} else if (strchr("L+j}\r\n", c)) {
|
} else if (strchr("L+j}\r\n", c) || (c == 'G' && forward)) {
|
||||||
// these operate on multi-lines forwards
|
// these operate on multi-lines forwards
|
||||||
p = begin_line(dot);
|
p = begin_line(dot);
|
||||||
do_cmd(c); // execute movement cmd
|
do_cmd(c); // execute movement cmd
|
||||||
@ -3781,7 +3784,7 @@ static void do_cmd(int c)
|
|||||||
} else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
|
} else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
|
||||||
// partial line copy text into a register and delete
|
// partial line copy text into a register and delete
|
||||||
dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word
|
dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word
|
||||||
} else if (strchr("cdykjHL+-{}\r\n", c1)) {
|
} else if (strchr("cdykjGHL+-{}\r\n", c1)) {
|
||||||
// whole line copy text into a register and delete
|
// whole line copy text into a register and delete
|
||||||
dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines
|
dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines
|
||||||
whole = 1;
|
whole = 1;
|
||||||
|
Loading…
Reference in New Issue
Block a user