Mercurial > vim
comparison src/getchar.c @ 11325:77f3b7316d8b v8.0.0548
patch 8.0.0548: saving the redo buffer only works one time
commit https://github.com/vim/vim/commit/d4863aa99e0527e9505c79cbeafc68a6832200bf
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Apr 7 19:50:12 2017 +0200
patch 8.0.0548: saving the redo buffer only works one time
Problem: Saving the redo buffer only works one time, resulting in the "."
command not working well for a function call inside another
function call. (Ingo Karkat)
Solution: Save the redo buffer at every user function call. (closes #1619)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Fri, 07 Apr 2017 20:00:04 +0200 |
parents | 501f46f7644c |
children | ff27a6a3a243 |
comparison
equal
deleted
inserted
replaced
11324:c9adf54ef624 | 11325:77f3b7316d8b |
---|---|
40 | 40 |
41 #define MINIMAL_SIZE 20 /* minimal size for b_str */ | 41 #define MINIMAL_SIZE 20 /* minimal size for b_str */ |
42 | 42 |
43 static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; | 43 static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0}; |
44 static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; | 44 static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; |
45 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) | |
46 static buffheader_T save_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; | |
47 static buffheader_T save_old_redobuff = {{NULL, {NUL}}, NULL, 0, 0}; | |
48 #endif | |
49 static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; | 45 static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0}; |
50 | 46 |
51 static int typeahead_char = 0; /* typeahead char that's not flushed */ | 47 static int typeahead_char = 0; /* typeahead char that's not flushed */ |
52 | 48 |
53 /* | 49 /* |
519 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) | 515 #if defined(FEAT_AUTOCMD) || defined(FEAT_EVAL) || defined(PROTO) |
520 /* | 516 /* |
521 * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff. | 517 * Save redobuff and old_redobuff to save_redobuff and save_old_redobuff. |
522 * Used before executing autocommands and user functions. | 518 * Used before executing autocommands and user functions. |
523 */ | 519 */ |
524 static int save_level = 0; | |
525 | |
526 void | 520 void |
527 saveRedobuff(void) | 521 saveRedobuff(save_redo_T *save_redo) |
528 { | 522 { |
529 char_u *s; | 523 char_u *s; |
530 | 524 |
531 if (save_level++ == 0) | 525 save_redo->sr_redobuff = redobuff; |
532 { | 526 redobuff.bh_first.b_next = NULL; |
533 save_redobuff = redobuff; | 527 save_redo->sr_old_redobuff = old_redobuff; |
534 redobuff.bh_first.b_next = NULL; | 528 old_redobuff.bh_first.b_next = NULL; |
535 save_old_redobuff = old_redobuff; | 529 |
536 old_redobuff.bh_first.b_next = NULL; | 530 /* Make a copy, so that ":normal ." in a function works. */ |
537 | 531 s = get_buffcont(&save_redo->sr_redobuff, FALSE); |
538 /* Make a copy, so that ":normal ." in a function works. */ | 532 if (s != NULL) |
539 s = get_buffcont(&save_redobuff, FALSE); | 533 { |
540 if (s != NULL) | 534 add_buff(&redobuff, s, -1L); |
541 { | 535 vim_free(s); |
542 add_buff(&redobuff, s, -1L); | |
543 vim_free(s); | |
544 } | |
545 } | 536 } |
546 } | 537 } |
547 | 538 |
548 /* | 539 /* |
549 * Restore redobuff and old_redobuff from save_redobuff and save_old_redobuff. | 540 * Restore redobuff and old_redobuff from save_redobuff and save_old_redobuff. |
550 * Used after executing autocommands and user functions. | 541 * Used after executing autocommands and user functions. |
551 */ | 542 */ |
552 void | 543 void |
553 restoreRedobuff(void) | 544 restoreRedobuff(save_redo_T *save_redo) |
554 { | 545 { |
555 if (--save_level == 0) | 546 free_buff(&redobuff); |
556 { | 547 redobuff = save_redo->sr_redobuff; |
557 free_buff(&redobuff); | 548 free_buff(&old_redobuff); |
558 redobuff = save_redobuff; | 549 old_redobuff = save_redo->sr_old_redobuff; |
559 free_buff(&old_redobuff); | |
560 old_redobuff = save_old_redobuff; | |
561 } | |
562 } | 550 } |
563 #endif | 551 #endif |
564 | 552 |
565 /* | 553 /* |
566 * Append "s" to the redo buffer. | 554 * Append "s" to the redo buffer. |