[vim/vim] Vim doesn't always truncate long messages printed to the command-line after :cnext and friends (#8652)

24 views
Skip to first unread message

bfrg

unread,
Jul 28, 2021, 9:49:37 AM7/28/21
to vim/vim, Subscribed

Describe the bug
Vim does not always truncate long quickfix errors that are printed to the command-line after running :cc, :cnext and friends. This seems to occur only when the cursor is already on the same line as the quickfix error.

To Reproduce

  1. Run vim --clean test.vim -S test.vim, with
    " test.vim
    call setqflist([
            \ {
            \   'bufnr': 1,
            \   'lnum': 1,
            \   'col': 1,
            \   'text': repeat('message ', 50)
            \ },
            \ {
            \   'bufnr': 1,
            \   'lnum': 3,
            \   'col': 9,
            \   'text': repeat('message ', 50)
            \ },
            \ {
            \   'bufnr': 1,
            \   'lnum': 3,
            \   'col': 20,
            \   'text': repeat('message ', 50)
            \ },
            \ {
            \   'bufnr': 1,
            \   'lnum': 5,
            \   'col': 9,
            \   'text': repeat('message ', 50)
            \ }
            \ ])
    Note: the second and third quickfix items are on the same line.
  2. Execute :cc.
  3. Result: the current error is not truncated to the window width, and the hit-enter-prompt shows up.
  4. Move the cursor to the next line and execute :cc again.
  5. Result: Now the error is truncated in the middle as desired.

It seems like when the error is on the same line as the cursor, the messages won't be truncated to fit into the window. This can also be observed with :cnext or :cprevious:

  1. Jump to the next error by running :cnext.
  2. Result: the message is correctly truncated (iff the cursor was not on that line).
  3. Run :cnext again to jump to the third error (which is on the same line as the second one).
  4. Result: when jumping to the third error, the entire message is printed.

Environment
Vim version 8.2.3134


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.

Gabriel Dupras

unread,
Jul 28, 2021, 10:38:19 AM7/28/21
to vim/vim, Subscribed

Could it be ignoring the O flag in 'shortmess'? From :help 'shortmess':

 O	message for reading a file overwrites any previous message.
	Also for quickfix message (e.g., ":cn").

Yegappan Lakshmanan

unread,
Jul 28, 2021, 11:12:05 AM7/28/21
to vim_dev, reply+ACY5DGH7NXUUC2XOZC...@reply.github.com, vim/vim, Subscribed
Hi,

On Wed, Jul 28, 2021 at 7:38 AM Gabriel Dupras <vim-dev...@256bit.org> wrote:

Could it be ignoring the O flag in 'shortmess'? From :help 'shortmess':

 O	message for reading a file overwrites any previous message.
	Also for quickfix message (e.g., ":cn").



Yes. This is controlled by the 'O' flag in 'shortmess'. If this flag is not
present, then the long messages will be displayed for the ":cnext" and ":cc"
commands.

- Yegappan

vim-dev ML

unread,
Jul 28, 2021, 11:12:21 AM7/28/21
to vim/vim, vim-dev ML, Your activity

Hi,

On Wed, Jul 28, 2021 at 7:38 AM Gabriel Dupras ***@***.***>

wrote:

> Could it be ignoring the O flag in 'shortmess'? From :help 'shortmess':
>
> O message for reading a file overwrites any previous message.
> Also for quickfix message (e.g., ":cn").
>
>
>
Yes. This is controlled by the 'O' flag in 'shortmess'. If this flag is not
present, then the long messages will be displayed for the ":cnext" and ":cc"
commands.

- Yegappan

Bram Moolenaar

unread,
Jul 28, 2021, 3:34:19 PM7/28/21
to vim/vim, vim-dev ML, Comment

This is intentional. When you are jumping around with ":cnext" you don't usually want to get the hit-enter prompt, you might not even look at the message. But sometimes you wonder what's wrong. Then you just type :cc and you'll see the whole message.
This is usually what you want, but not always. Perhaps we should not show the whole message when using :cnext, only when using :cc?


You are receiving this because you commented.

bfrg

unread,
Jul 28, 2021, 7:23:57 PM7/28/21
to vim/vim, vim-dev ML, Comment

When you are jumping around with ":cnext" you don't usually want to get the hit-enter prompt, you might not even look at the message

Yes, I agree. But the current behavior is inconsistent. When there are two errors on the same line and you execute :cnext to jump to the first error of that line, there's no hit-enter prompt. But when you execute :cnext again to jump to the next error on the same line, the whole message of the second error is printed, and that can be annoying.

It looks like Vim checks the current cursor position and if it's on the same line as the next error, the whole message is printed.

Perhaps we should not show the whole message when using :cnext, only when using :cc?

The whole message is printed after :cc only if the cursor is on the same line as the current error. For example, when you source the above script and you move the cursor to the bottom and run :cc, Vim will jump to (1, 1) and print the truncated message. But when you leave the cursor anywhere on the first line and run :cc, the whole message is printed. For me that's an inconsistency.

I do use :cnext and :cprevious a lot, but often there are multiple errors/warnings on the same line. When I jump to the first one, there's no hit-enter prompt but when I go to the next ones I get the entire message printed which pops up the hit-enter prompt.


You are receiving this because you commented.

Bram Moolenaar

unread,
Jul 29, 2021, 4:26:05 PM7/29/21
to vim...@googlegroups.com, bfrg

> > When you are jumping around with ":cnext" you don't usually want to
> > get the hit-enter prompt, you might not even look at the message
>
> Yes, I agree. But the current behavior is inconsistent. When there are
> two errors on the _same_ line and you execute `:cnext` to jump to the
> first error of that line, there's no hit-enter prompt. But when you
> execute `:cnext` again to jump to the next error on the same line, the
> whole message of the second error is printed, and that can be
> annoying.
>
> It looks like Vim checks the current cursor position and if it's on
> the same line as the next error, the whole message is printed.

Yes. It's a compromise. The idea is that when the error is in the same
line you are at least not jumping to another file or scrolling the text.
But the prompt can still be annoying.

> > Perhaps we should not show the whole message when using :cnext,
> > only when using :cc?
>
> The whole message is printed after `:cc` only if the cursor is on the
> same line as the current error. For example, when you source the above
> script and you move the cursor to the bottom and run `:cc`, Vim will
> jump to (1, 1) and print the truncated message. But when you leave the
> cursor _anywhere_ on the first line and run `:cc`, the whole message
> is printed. For me that's an inconsistency.

That is intentional. If :cc has to jump, possibly to another file, you
probably don't want to see the whole message. If you already are on the
right line, there is no point to use :cc for jumping. So it shows
the whole message. It's the simplest way to show the whole message
(without adding another command or temporarily changing an option).

> I do use `:cnext` and `:cprevious` a lot, but often there are multiple
> errors/warnings on the same line. When I jump to the first one,
> there's no hit-enter prompt but when I go to the next ones I get the
> entire message printed which pops up the hit-enter prompt.

That's why I suggested that maybe :cnext should not show the whole
message, even when already in the right line. You might not know the
next error is in the same line.

--
In his lifetime van Gogh painted 486 oil paintings. Oddly enough, 8975
of them are to be found in the United States.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
Reply all
Reply to author
Forward
0 new messages