[vim/vim] Errorformat: handling of %v in multi-line messages (#7145)

12 views
Skip to first unread message

matze-dd

unread,
Oct 16, 2020, 10:24:47 AM10/16/20
to vim/vim, Subscribed

Describe the bug
In single-line messages parsed with errorformat, code %v correctly treats column numbers, if multi-byte characters occur in front of the indicated error on the current line.

In multi-line messages, this does not always work.

To Reproduce
In the following, a working and a not working example are given. Assume the text file t.txt (UTF-8) with the leading multi-byte character ä:

ä test

We have two compilers, both reporting a problem starting at column 3. This is m1.sh:

#!/bin/bash

echo "=== t.txt ==="

echo "1:3:an error"

Compiler m2.sh returns the error message text on a third line:

#!/bin/bash

echo "=== t.txt ==="

echo "1:3"

echo "an error"

If one now says, for the first compiler,

:set errorformat=%I===\ %f\ ===,%Z%l:%v:%m

:set makeprg=./m1.sh

then after :make the quickfix window (:cw) is

t.txt|1 col 3 info|  an error

After hitting Enter in the quickfix window, the cursor is correctly placed at the beginning of test (screen column 3).

For the second compiler, we say

:set errorformat=%I===\ %f\ ===,%C%l:%v,%Z%m

:set makeprg=./m2.sh

The quickfix window shows exactly the same message as in the first case, but on Enter, the cursor goes to the second screen column, i.e., to the space between ä and test.

Expected behavior
If errorformat is correct (which I'm not absolutely sure about), the second example should place the cursor in screen column 3, too.

Environment (please complete the following information):

  • Vim version 8.2.1847
  • OS: Lubuntu 20.04
  • Terminal: qterminal 0.14.1

Additional context
File quickfix.c contains in function qf_parse_multiline_pfx() the line 1366

	qfprev->qf_viscol = fields->use_viscol;

If one replaces it (similarly to the adjacent statements) with

        if (!qfprev->qf_viscol)

            qfprev->qf_viscol = fields->use_viscol;

then the reported problem vanishes. But this is not more than a guess, so I cannot provide a PR.


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

Christian Brabandt

unread,
Oct 18, 2020, 10:43:05 AM10/18/20
to vim/vim, Subscribed

you could create a PR and we would see if any tests fail.

matze-dd

unread,
Oct 19, 2020, 11:04:31 AM10/19/20
to vim/vim, Subscribed

The PR is #7169, quote from there:

Although all tests on Travis CI passed, I have a bad feeling with this PR. The change is more an "educated guess", as I do not really understand the machinery at work. There seem to be no tests for %v with multi-line massages in test_quickfix.c.

Yegappan Lakshmanan

unread,
Oct 19, 2020, 11:25:51 AM10/19/20
to vim_dev, reply+ACY5DGA5DVFGGKJDEO...@reply.github.com, vim/vim, Subscribed
Hi,

On Mon, Oct 19, 2020 at 8:03 AM matze-dd <vim-dev...@256bit.org> wrote:

The PR is #7169, quote from there:

Although all tests on Travis CI passed, I have a bad feeling with this PR. The change is more an "educated guess", as I do not really understand the machinery at work. There seem to be no tests for %v with multi-line massages in test_quickfix.c.


The qf_viscol field should be set whenever the qf_col field is set. So the change
should look like:

 if (!qfprev->qf_col)
{
   qfprev->qf_col = fields->col;

   qfprev->qf_viscol = fields->use_viscol;
}

- Yegappan

vim-dev ML

unread,
Oct 19, 2020, 11:26:13 AM10/19/20
to vim/vim, vim-dev ML, Your activity

Hi,

On Mon, Oct 19, 2020 at 8:03 AM matze-dd <vim-dev...@256bit.org> wrote:

> The PR is #7169 <https://github.com/vim/vim/pull/7169>, quote from there:

>
> Although all tests on Travis CI passed, I have a bad feeling with this PR.
> The change is more an "educated guess", as I do not really understand the
> machinery at work. There seem to be no tests for %v with multi-line
> massages in test_quickfix.c.
>
>
> The qf_viscol field should be set whenever the qf_col field is set. So the
change
should look like:

if (!qfprev->qf_col)
{
qfprev->qf_col = fields->col;
qfprev->qf_viscol = fields->use_viscol;
}

- Yegappan

matze-dd

unread,
Oct 20, 2020, 9:19:43 AM10/20/20
to vim/vim, vim-dev ML, Comment

The PR has been merged.


You are receiving this because you commented.

matze-dd

unread,
Oct 20, 2020, 9:19:44 AM10/20/20
to vim/vim, vim-dev ML, Comment

Closed #7145.


You are receiving this because you commented.

Reply all
Reply to author
Forward
0 new messages