diff options
-rw-r--r-- | editors/vi.c | 30 |
1 files changed, 12 insertions, 18 deletions
diff --git a/editors/vi.c b/editors/vi.c index b77406967..922d7ea8d 100644 --- a/editors/vi.c +++ b/editors/vi.c | |||
@@ -377,7 +377,6 @@ struct globals { | |||
377 | char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27 | 377 | char *reg[28]; // named register a-z, "D", and "U" 0-25,26,27 |
378 | char regtype[28]; // buffer type: WHOLE, MULTI or PARTIAL | 378 | char regtype[28]; // buffer type: WHOLE, MULTI or PARTIAL |
379 | char *mark[28]; // user marks points somewhere in text[]- a-z and previous context '' | 379 | char *mark[28]; // user marks points somewhere in text[]- a-z and previous context '' |
380 | char *context_start, *context_end; | ||
381 | #endif | 380 | #endif |
382 | #if ENABLE_FEATURE_VI_USE_SIGNALS | 381 | #if ENABLE_FEATURE_VI_USE_SIGNALS |
383 | sigjmp_buf restart; // int_handler() jumps to location remembered here | 382 | sigjmp_buf restart; // int_handler() jumps to location remembered here |
@@ -496,8 +495,6 @@ struct globals { | |||
496 | //#define Ureg (G.Ureg ) | 495 | //#define Ureg (G.Ureg ) |
497 | #define regtype (G.regtype ) | 496 | #define regtype (G.regtype ) |
498 | #define mark (G.mark ) | 497 | #define mark (G.mark ) |
499 | #define context_start (G.context_start ) | ||
500 | #define context_end (G.context_end ) | ||
501 | #define restart (G.restart ) | 498 | #define restart (G.restart ) |
502 | #define term_orig (G.term_orig ) | 499 | #define term_orig (G.term_orig ) |
503 | #define cindex (G.cindex ) | 500 | #define cindex (G.cindex ) |
@@ -1415,18 +1412,10 @@ static char what_reg(void) | |||
1415 | 1412 | ||
1416 | static void check_context(char cmd) | 1413 | static void check_context(char cmd) |
1417 | { | 1414 | { |
1418 | // A context is defined to be "modifying text" | 1415 | // Certain movement commands update the context. |
1419 | // Any modifying command establishes a new context. | 1416 | if (strchr(":%{}'GHLMz/?Nn", cmd) != NULL) { |
1420 | 1417 | mark[27] = mark[26]; // move cur to prev | |
1421 | if (dot < context_start || dot > context_end) { | 1418 | mark[26] = dot; // move local to cur |
1422 | if (strchr(modifying_cmds, cmd) != NULL) { | ||
1423 | // we are trying to modify text[]- make this the current context | ||
1424 | mark[27] = mark[26]; // move cur to prev | ||
1425 | mark[26] = dot; // move local to cur | ||
1426 | context_start = prev_line(prev_line(dot)); | ||
1427 | context_end = next_line(next_line(dot)); | ||
1428 | //loiter= start_loiter= now; | ||
1429 | } | ||
1430 | } | 1419 | } |
1431 | } | 1420 | } |
1432 | 1421 | ||
@@ -1441,8 +1430,6 @@ static char *swap_context(char *p) // goto new context for '' command make this | |||
1441 | tmp = mark[27]; | 1430 | tmp = mark[27]; |
1442 | mark[27] = p; | 1431 | mark[27] = p; |
1443 | mark[26] = p = tmp; | 1432 | mark[26] = p = tmp; |
1444 | context_start = prev_line(prev_line(prev_line(p))); | ||
1445 | context_end = next_line(next_line(next_line(p))); | ||
1446 | } | 1433 | } |
1447 | return p; | 1434 | return p; |
1448 | } | 1435 | } |
@@ -3287,6 +3274,9 @@ static void do_cmd(int c) | |||
3287 | int dir; | 3274 | int dir; |
3288 | int cnt, i, j; | 3275 | int cnt, i, j; |
3289 | int c1; | 3276 | int c1; |
3277 | #if ENABLE_FEATURE_VI_YANKMARK | ||
3278 | char *orig_dot = dot; | ||
3279 | #endif | ||
3290 | #if ENABLE_FEATURE_VI_UNDO | 3280 | #if ENABLE_FEATURE_VI_UNDO |
3291 | int allow_undo = ALLOW_UNDO; | 3281 | int allow_undo = ALLOW_UNDO; |
3292 | int undo_del = UNDO_DEL; | 3282 | int undo_del = UNDO_DEL; |
@@ -3480,6 +3470,9 @@ static void do_cmd(int c) | |||
3480 | dot = swap_context(dot); // swap current and previous context | 3470 | dot = swap_context(dot); // swap current and previous context |
3481 | dot_begin(); // go to B-o-l | 3471 | dot_begin(); // go to B-o-l |
3482 | dot_skip_over_ws(); | 3472 | dot_skip_over_ws(); |
3473 | #if ENABLE_FEATURE_VI_YANKMARK | ||
3474 | orig_dot = dot; // this doesn't update stored contexts | ||
3475 | #endif | ||
3483 | } else { | 3476 | } else { |
3484 | indicate_error(); | 3477 | indicate_error(); |
3485 | } | 3478 | } |
@@ -4109,7 +4102,8 @@ static void do_cmd(int c) | |||
4109 | dot = bound_dot(dot); // make sure "dot" is valid | 4102 | dot = bound_dot(dot); // make sure "dot" is valid |
4110 | } | 4103 | } |
4111 | #if ENABLE_FEATURE_VI_YANKMARK | 4104 | #if ENABLE_FEATURE_VI_YANKMARK |
4112 | check_context(c); // update the current context | 4105 | if (dot != orig_dot) |
4106 | check_context(c); // update the current context | ||
4113 | #endif | 4107 | #endif |
4114 | 4108 | ||
4115 | if (!isdigit(c)) | 4109 | if (!isdigit(c)) |