aboutsummaryrefslogtreecommitdiff
path: root/editors/vi.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2019-05-27 11:56:52 +0100
committerRon Yorston <rmy@pobox.com>2019-05-27 11:56:52 +0100
commita61949401890cbb33a9d6c4571b51c53460ad438 (patch)
tree64dedaddb89896d5b1670a421af123670ca2120b /editors/vi.c
parent03a7b173605a890e1db5177ecd5b8dd591081c41 (diff)
parentbcb1fc3e6ca6fe902610f507eaf9b0b58a5c583a (diff)
downloadbusybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.gz
busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.tar.bz2
busybox-w32-a61949401890cbb33a9d6c4571b51c53460ad438.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'editors/vi.c')
-rw-r--r--editors/vi.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/editors/vi.c b/editors/vi.c
index a8b4dc5a4..70c8f3daf 100644
--- a/editors/vi.c
+++ b/editors/vi.c
@@ -3067,11 +3067,14 @@ static void do_cmd(int c);
3067static int find_range(char **start, char **stop, char c) 3067static int find_range(char **start, char **stop, char c)
3068{ 3068{
3069 char *save_dot, *p, *q, *t; 3069 char *save_dot, *p, *q, *t;
3070 int cnt, multiline = 0; 3070 int cnt, multiline = 0, forward;
3071 3071
3072 save_dot = dot; 3072 save_dot = dot;
3073 p = q = dot; 3073 p = q = dot;
3074 3074
3075 // will a 'G' command move forwards or backwards?
3076 forward = cmdcnt == 0 || cmdcnt > count_lines(text, dot);
3077
3075 if (strchr("cdy><", c)) { 3078 if (strchr("cdy><", c)) {
3076 // these cmds operate on whole lines 3079 // these cmds operate on whole lines
3077 p = q = begin_line(p); 3080 p = q = begin_line(p);
@@ -3095,13 +3098,13 @@ static int find_range(char **start, char **stop, char c)
3095 if (dot > text && *dot == '\n') 3098 if (dot > text && *dot == '\n')
3096 dot--; // stay off NL 3099 dot--; // stay off NL
3097 q = dot; 3100 q = dot;
3098 } else if (strchr("H-k{", c)) { 3101 } else if (strchr("H-k{", c) || (c == 'G' && !forward)) {
3099 // these operate on multi-lines backwards 3102 // these operate on multi-lines backwards
3100 q = end_line(dot); // find NL 3103 q = end_line(dot); // find NL
3101 do_cmd(c); // execute movement cmd 3104 do_cmd(c); // execute movement cmd
3102 dot_begin(); 3105 dot_begin();
3103 p = dot; 3106 p = dot;
3104 } else if (strchr("L+j}\r\n", c)) { 3107 } else if (strchr("L+j}\r\n", c) || (c == 'G' && forward)) {
3105 // these operate on multi-lines forwards 3108 // these operate on multi-lines forwards
3106 p = begin_line(dot); 3109 p = begin_line(dot);
3107 do_cmd(c); // execute movement cmd 3110 do_cmd(c); // execute movement cmd
@@ -3836,11 +3839,10 @@ static void do_cmd(int c)
3836 if (c1 == 27) { // ESC- user changed mind and wants out 3839 if (c1 == 27) { // ESC- user changed mind and wants out
3837 c = c1 = 27; // Escape- do nothing 3840 c = c1 = 27; // Escape- do nothing
3838 } else if (strchr("wW", c1)) { 3841 } else if (strchr("wW", c1)) {
3842 ml = 0; // multi-line ranges aren't allowed for words
3839 if (c == 'c') { 3843 if (c == 'c') {
3840 // don't include trailing WS as part of word 3844 // don't include trailing WS as part of word
3841 while (isblank(*q)) { 3845 while (isspace(*q) && q > p) {
3842 if (q <= text || q[-1] == '\n')
3843 break;
3844 q--; 3846 q--;
3845 } 3847 }
3846 } 3848 }
@@ -3848,7 +3850,7 @@ static void do_cmd(int c)
3848 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) { 3850 } else if (strchr("^0bBeEft%$ lh\b\177", c1)) {
3849 // partial line copy text into a register and delete 3851 // partial line copy text into a register and delete
3850 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word 3852 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete word
3851 } else if (strchr("cdykjHL+-{}\r\n", c1)) { 3853 } else if (strchr("cdykjGHL+-{}\r\n", c1)) {
3852 // whole line copy text into a register and delete 3854 // whole line copy text into a register and delete
3853 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines 3855 dot = yank_delete(p, q, ml, yf, ALLOW_UNDO); // delete lines
3854 whole = 1; 3856 whole = 1;