To: vim-dev@vim.org Subject: patch 5.5.058 Fcc: outbox From: Bram Moolenaar ------------ Patch 5.5.058 Problem: Using a long search pattern and then "n" causes the hit-return prompt. (Krishna) Solution: Truncate the echoed pattern, like other messages. Moved code for truncating from msg_attr() to msg_strtrunc(). Files: src/message.c, src/proto/message.pro, src/search.c *** ../vim-5.5.57/src/message.c Sat Dec 4 20:31:11 1999 --- src/message.c Mon Dec 6 17:58:35 1999 *************** *** 95,104 **** { static int entered = 0; int retval; - int len; - int room; - int half; - int i; char_u *buf = NULL; /* --- 95,100 ---- *************** *** 119,124 **** --- 115,148 ---- && STRCMP(s, last_msg_hist->msg))) add_msg_hist(s, -1, attr); + /* Truncate the message if needed. */ + buf = msg_strtrunc(s); + if (buf != NULL) + s = buf; + + msg_start(); + msg_outtrans_attr(s, attr); + msg_clr_eos(); + retval = msg_end(); + + vim_free(buf); + --entered; + return retval; + } + + /* + * Truncate a string such that it can be printed without causing a scroll. + */ + char_u * + msg_strtrunc(s) + char_u *s; + { + char_u *buf = NULL; + int len; + int room; + int half; + int i; + /* May truncate message to avoid a hit-return prompt */ if (!msg_scroll && !need_wait_return && shortmess(SHM_TRUNCALL) && !exmode_active) *************** *** 146,164 **** if (len > room) ++i; STRCAT(buf, s + i + 1); - s = buf; } } } ! ! msg_start(); ! msg_outtrans_attr(s, attr); ! msg_clr_eos(); ! retval = msg_end(); ! ! vim_free(buf); ! --entered; ! return retval; } /* --- 170,179 ---- if (len > room) ++i; STRCAT(buf, s + i + 1); } } } ! return buf; } /* *** ../vim-5.5.57/src/proto/message.pro Wed Sep 22 10:06:13 1999 --- src/proto/message.pro Mon Dec 6 17:58:54 1999 *************** *** 1,6 **** --- 1,7 ---- /* message.c */ int msg __ARGS((char_u *s)); int msg_attr __ARGS((char_u *s, int attr)); + char_u *msg_strtrunc __ARGS((char_u *s)); int emsg __ARGS((char_u *s)); int emsg2 __ARGS((char_u *s, char_u *a1)); int emsgn __ARGS((char_u *s, long n)); *** ../vim-5.5.57/src/search.c Tue Oct 19 20:45:17 1999 --- src/search.c Mon Dec 6 18:07:12 1999 *************** *** 755,784 **** if ((options & SEARCH_ECHO) && messaging()) { ! msg_start(); ! msg_putchar(dirc); ! msg_outtrans(*searchstr == NUL ? spats[last_idx].pat : searchstr); ! if (spats[0].off.line || spats[0].off.end || spats[0].off.off) { ! msg_putchar(dirc); ! if (spats[0].off.end) ! msg_putchar('e'); ! else if (!spats[0].off.line) ! msg_putchar('s'); ! if (spats[0].off.off < 0) ! msg_outnum((long)spats[0].off.off); ! else if (spats[0].off.off > 0 || spats[0].off.line) { ! msg_putchar('+'); ! msg_outnum((long)spats[0].off.off); } - } - msg_clr_eos(); - msg_check(); ! gotocmdline(FALSE); ! out_flush(); ! msg_nowait = TRUE; /* don't wait for this message */ } /* --- 755,803 ---- if ((options & SEARCH_ECHO) && messaging()) { ! char_u *msgbuf; ! char_u *trunc; ! ! if (*searchstr == NUL) ! p = spats[last_idx].pat; ! else ! p = searchstr; ! msgbuf = alloc((unsigned)(STRLEN(p) + 40)); ! if (msgbuf != NULL) { ! msgbuf[0] = dirc; ! STRCPY(msgbuf + 1, p); ! if (spats[0].off.line || spats[0].off.end || spats[0].off.off) { ! p = msgbuf + STRLEN(msgbuf); ! *p++ = dirc; ! if (spats[0].off.end) ! *p++ = 'e'; ! else if (!spats[0].off.line) ! *p++ = 's'; ! if (spats[0].off.off > 0 || spats[0].off.line) ! *p++ = '+'; ! if (spats[0].off.off != 0 || spats[0].off.line) ! sprintf(p, "%ld", spats[0].off.off); } ! msg_start(); ! trunc = msg_strtrunc(msgbuf); ! if (trunc != NULL) ! { ! msg_outtrans(trunc); ! vim_free(trunc); ! } ! else ! msg_outtrans(msgbuf); ! msg_clr_eos(); ! msg_check(); ! vim_free(msgbuf); ! ! gotocmdline(FALSE); ! out_flush(); ! msg_nowait = TRUE; /* don't wait for this message */ ! } } /* *** ../vim-5.5.57/src/version.c Mon Dec 6 18:13:12 1999 --- src/version.c Mon Dec 6 18:12:26 1999 *************** *** 420,420 **** --- 420,421 ---- { /* Add new patch number below this line */ + 58, -- hundred-and-one symptoms of being an internet addict: 257. You turn to the teletext page "surfing report" and are surprised that it is about sizes of waves and a weather forecast for seaside resorts. --/-/---- Bram Moolenaar ---- Bram@moolenaar.net ---- Bram@vim.org ---\-\-- \ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /