comparison src/message.c @ 29515:e988bbf50e09 v9.0.0099

patch 9.0.0099: scrollback can be wrong after redrawing the command line Commit: https://github.com/vim/vim/commit/46af7bc08debbf408d025680eeef136fb3b528ef Author: zeertzjq <zeertzjq@outlook.com> Date: Thu Jul 28 12:34:09 2022 +0100 patch 9.0.0099: scrollback can be wrong after redrawing the command line Problem: Scrollback can be wrong after redrawing the command line. Solution: Clear unfinished scrollback when redrawing. (closes https://github.com/vim/vim/issues/10807)
author Bram Moolenaar <Bram@vim.org>
date Thu, 28 Jul 2022 13:45:04 +0200
parents 7a2569ab418e
children 8a243ecfe2dd
comparison
equal deleted inserted replaced
29514:d5fdad5eaf16 29515:e988bbf50e09
2533 2533
2534 if (do_clear_sb_text == SB_CLEAR_ALL 2534 if (do_clear_sb_text == SB_CLEAR_ALL
2535 || do_clear_sb_text == SB_CLEAR_CMDLINE_DONE) 2535 || do_clear_sb_text == SB_CLEAR_CMDLINE_DONE)
2536 { 2536 {
2537 clear_sb_text(do_clear_sb_text == SB_CLEAR_ALL); 2537 clear_sb_text(do_clear_sb_text == SB_CLEAR_ALL);
2538 msg_sb_eol(); // prevent messages from overlapping
2538 do_clear_sb_text = SB_CLEAR_NONE; 2539 do_clear_sb_text = SB_CLEAR_NONE;
2539 } 2540 }
2540 2541
2541 if (s > *sb_str) 2542 if (s > *sb_str)
2542 { 2543 {
2577 { 2578 {
2578 do_clear_sb_text = SB_CLEAR_ALL; 2579 do_clear_sb_text = SB_CLEAR_ALL;
2579 } 2580 }
2580 2581
2581 /* 2582 /*
2582 * Starting to edit the command line, do not clear messages now. 2583 * Starting to edit the command line: do not clear messages now.
2583 */ 2584 */
2584 void 2585 void
2585 sb_text_start_cmdline(void) 2586 sb_text_start_cmdline(void)
2586 { 2587 {
2588 if (do_clear_sb_text == SB_CLEAR_CMDLINE_BUSY)
2589 // Invoking command line recursively: the previous-level command line
2590 // doesn't need to be remembered as it will be redrawn when returning
2591 // to that level.
2592 sb_text_restart_cmdline();
2593 else
2594 {
2595 msg_sb_eol();
2596 do_clear_sb_text = SB_CLEAR_CMDLINE_BUSY;
2597 }
2598 }
2599
2600 /*
2601 * Redrawing the command line: clear the last unfinished line.
2602 */
2603 void
2604 sb_text_restart_cmdline(void)
2605 {
2606 msgchunk_T *tofree;
2607
2608 // Needed when returning from nested command line.
2587 do_clear_sb_text = SB_CLEAR_CMDLINE_BUSY; 2609 do_clear_sb_text = SB_CLEAR_CMDLINE_BUSY;
2588 msg_sb_eol(); 2610
2589 } 2611 if (last_msgchunk == NULL || last_msgchunk->sb_eol)
2590 2612 // No unfinished line: don't clear anything.
2591 /* 2613 return;
2592 * Ending to edit the command line. Clear old lines but the last one later. 2614
2615 tofree = msg_sb_start(last_msgchunk);
2616 last_msgchunk = tofree->sb_prev;
2617 if (last_msgchunk != NULL)
2618 last_msgchunk->sb_next = NULL;
2619 while (tofree != NULL)
2620 {
2621 msgchunk_T *tofree_next = tofree->sb_next;
2622
2623 vim_free(tofree);
2624 tofree = tofree_next;
2625 }
2626 }
2627
2628 /*
2629 * Ending to edit the command line: clear old lines but the last one later.
2593 */ 2630 */
2594 void 2631 void
2595 sb_text_end_cmdline(void) 2632 sb_text_end_cmdline(void)
2596 { 2633 {
2597 do_clear_sb_text = SB_CLEAR_CMDLINE_DONE; 2634 do_clear_sb_text = SB_CLEAR_CMDLINE_DONE;
2598 msg_sb_eol();
2599 } 2635 }
2600 2636
2601 /* 2637 /*
2602 * Clear any text remembered for scrolling back. 2638 * Clear any text remembered for scrolling back.
2603 * When "all" is FALSE keep the last line. 2639 * When "all" is FALSE keep the last line.