diff options
Diffstat (limited to 'src/message.c')
-rw-r--r-- | src/message.c | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/src/message.c b/src/message.c index 7ba82fa050..50a174928c 100644 --- a/src/message.c +++ b/src/message.c @@ -2535,6 +2535,7 @@ store_sb_text( || do_clear_sb_text == SB_CLEAR_CMDLINE_DONE) { clear_sb_text(do_clear_sb_text == SB_CLEAR_ALL); + msg_sb_eol(); // prevent messages from overlapping do_clear_sb_text = SB_CLEAR_NONE; } @@ -2579,23 +2580,58 @@ may_clear_sb_text(void) } /* - * Starting to edit the command line, do not clear messages now. + * Starting to edit the command line: do not clear messages now. */ void sb_text_start_cmdline(void) { + if (do_clear_sb_text == SB_CLEAR_CMDLINE_BUSY) + // Invoking command line recursively: the previous-level command line + // doesn't need to be remembered as it will be redrawn when returning + // to that level. + sb_text_restart_cmdline(); + else + { + msg_sb_eol(); + do_clear_sb_text = SB_CLEAR_CMDLINE_BUSY; + } +} + +/* + * Redrawing the command line: clear the last unfinished line. + */ + void +sb_text_restart_cmdline(void) +{ + msgchunk_T *tofree; + + // Needed when returning from nested command line. do_clear_sb_text = SB_CLEAR_CMDLINE_BUSY; - msg_sb_eol(); + + if (last_msgchunk == NULL || last_msgchunk->sb_eol) + // No unfinished line: don't clear anything. + return; + + tofree = msg_sb_start(last_msgchunk); + last_msgchunk = tofree->sb_prev; + if (last_msgchunk != NULL) + last_msgchunk->sb_next = NULL; + while (tofree != NULL) + { + msgchunk_T *tofree_next = tofree->sb_next; + + vim_free(tofree); + tofree = tofree_next; + } } /* - * Ending to edit the command line. Clear old lines but the last one later. + * Ending to edit the command line: clear old lines but the last one later. */ void sb_text_end_cmdline(void) { do_clear_sb_text = SB_CLEAR_CMDLINE_DONE; - msg_sb_eol(); } /* |