Skip to content

Proposal: Add end_lnum and end_col to quickfix entry#8393

Closed
thinca wants to merge 3 commits intovim:masterfrom
thinca:add-end_lnum-and-end_col-to-quickfix
Closed

Proposal: Add end_lnum and end_col to quickfix entry#8393
thinca wants to merge 3 commits intovim:masterfrom
thinca:add-end_lnum-and-end_col-to-quickfix

Conversation

@thinca
Copy link
Contributor

@thinca thinca commented Jun 16, 2021

Modern tools may be able to specify a range when outputting the location of the source code.

  • LSP reports the location of errors etc. in the range.
  • The Rust compiler can report error locations in a range.
  • ripgrep can get information on the end position of the match in JSON format.

Quickfix is ​​a common part of Vim, where many plugins output location information to here, and many plugins get location information from here.

The fact that the quickfix entry has range information creates orthogonality between plugins.

For example, we can create a plugin that properly highlights the range specified by quickfix.

For example, even if there are multiple errors on the same line, we can pop up the appropriate error message for the cursor position.

If quickfix doesn't have range information, we can only collect location information and highlight it in one plugin. This is because there is no way to pass information between plugins.

This pull request does not contain any changes regarding errorformat. I think it will be necessary eventually, but first I made a pull request at this stage to see if this proposal would be accepted.

What do you think about this?

@thinca thinca force-pushed the add-end_lnum-and-end_col-to-quickfix branch from 558522a to 909665b Compare June 16, 2021 16:51
@thinca thinca force-pushed the add-end_lnum-and-end_col-to-quickfix branch from 909665b to 2f777c5 Compare June 16, 2021 17:05
@codecov
Copy link

codecov bot commented Jun 16, 2021

Codecov Report

Merging #8393 (79a76d6) into master (41a7f82) will decrease coverage by 0.08%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8393      +/-   ##
==========================================
- Coverage   89.85%   89.76%   -0.09%     
==========================================
  Files         149      149              
  Lines      167465   165940    -1525     
==========================================
- Hits       150469   148960    -1509     
+ Misses      16996    16980      -16     
Flag Coverage Δ
huge-clang-none 88.74% <100.00%> (-0.32%) ⬇️
huge-gcc-none 89.31% <100.00%> (+<0.01%) ⬆️
huge-gcc-testgui 87.80% <100.00%> (+<0.01%) ⬆️
huge-gcc-unittests 2.50% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/quickfix.c 94.90% <100.00%> (+0.03%) ⬆️
src/sound.c 95.87% <0.00%> (-1.13%) ⬇️
src/if_xcmdsrv.c 88.13% <0.00%> (-1.13%) ⬇️
src/help.c 89.76% <0.00%> (-1.08%) ⬇️
src/textobject.c 91.69% <0.00%> (-0.71%) ⬇️
src/ex_cmds2.c 90.93% <0.00%> (-0.54%) ⬇️
src/beval.c 82.81% <0.00%> (-0.53%) ⬇️
src/mbyte.c 80.09% <0.00%> (-0.52%) ⬇️
src/term.c 82.42% <0.00%> (-0.50%) ⬇️
src/libvterm/src/screen.c 60.11% <0.00%> (-0.47%) ⬇️
... and 59 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 41a7f82...79a76d6. Read the comment docs.

@brammool
Copy link
Contributor

Thanks, this can be useful.
I'll let @yegappan make comments, he has been doing work on quickfix code.

@vim-ml
Copy link

vim-ml commented Jun 17, 2021 via email

@thinca
Copy link
Contributor Author

thinca commented Jun 17, 2021

@brammool @yegappan Thank you for review! I'll try to add some tests later(maybe tonight).

@thinca
Copy link
Contributor Author

thinca commented Jun 17, 2021

I added some patterns to existing test cases. Is this enough?

I tweaked representation of range in quickfix window/:clist.

lnum end_lnum col end_col representation
yes no no no 10
yes no yes no 10 col 5
yes no yes yes 10 col 5-8
yes yes no no 10-12
yes yes yes no 10-12 col 5
yes yes yes yes 10-12 col 5-8

@vim-ml
Copy link

vim-ml commented Jun 18, 2021 via email

call assert_equal(1, line('$'))
call assert_equal(['Xfile1|10| aa'], getline(1, '$'))
call assert_equal([{'lnum': 10, 'bufnr': bufnr('Xfile1'), 'col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist())
call assert_equal([{'lnum': 10, 'end_lnum': 0, 'bufnr': bufnr('Xfile1'), 'col': 0, 'end_col': 0, 'pattern': '', 'valid': 1, 'vcol': 0, 'nr': -1, 'type': '', 'module': '', 'text': 'aa'}], getqflist())

This comment was marked as off-topic.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't worry.
end_lnum and end_col are just optional values. The text in the quickfix window is never changed when they are zero. It will be displayed as before. See the comment above.

This comment was marked as off-topic.

@brammool brammool closed this in 6864efa Jun 19, 2021
@thinca thinca deleted the add-end_lnum-and-end_col-to-quickfix branch June 19, 2021 23:13
janlazo added a commit to janlazo/neovim that referenced this pull request Jul 31, 2021
Problem:    Location list only has the start position.
Solution:   Make it possible to add an end position. (Shane-XB-Qian,
            closes vim/vim#8393)
vim/vim@6864efa

N/A patches for version.c:

vim-patch:8.2.3002: Vim doesn't abort on a fatal Tcl error

Problem:    Vim doesn't abort on a fatal Tcl error.
Solution:   Change emsg() to iemsg(). (Dominique Pellé, closes vim/vim#8383)
vim/vim@affd0bc

vim-patch:8.2.3030: Coverity reports a memory leak

Problem:    Coverity reports a memory leak.
Solution:   Fix the leak and a few typos. (Dominique Pellé, closes vim/vim#8418)
vim/vim@cb54bc6

Patch v8.2.3022 is mostly N/A but cannot be included here
because of new feature check for "has()".

vim-patch:8.2.3032: build problems with MSVC, other crypt issues with libsodium

Problem:    Build problems with MSVC, other crypt issues with libsodium.
Solution:   Adjust MSVC makefile. Disable swap file only when 'key' is set.
            Adjust error message used when key is wrong.  Fix Coverity issues.
            (Christian Brabandt, closes vim/vim#8420, closes vim/vim#8411)
vim/vim@226b28b

vim-patch:8.2.3044: Amiga MorphOS and AROS: process ID is not valid

Problem:    Amiga MorphOS and AROS: process ID is not valid.
Solution:   Use FindTask to return something which is unique to all processes.
            (Ola Söder, closes vim/vim#8444)
vim/vim@3a62b14

vim-patch:8.2.3046: Amiga MorphOS: Term mode is set using DOS packets

Problem:    Amiga MorphOS: Term mode is set using DOS packets.
Solution:   Use the same way of setting term mdoe on all next gen Amiga-like
            systems.  (Ola Söder, closes vim/vim#8445)
vim/vim@b420ac9
lewis6991 pushed a commit to lewis6991/neovim that referenced this pull request Dec 12, 2021
Problem:    Location list only has the start position.
Solution:   Make it possible to add an end position. (Shane-XB-Qian,
            closes vim/vim#8393)
vim/vim@6864efa

N/A patches for version.c:

vim-patch:8.2.3002: Vim doesn't abort on a fatal Tcl error

Problem:    Vim doesn't abort on a fatal Tcl error.
Solution:   Change emsg() to iemsg(). (Dominique Pellé, closes vim/vim#8383)
vim/vim@affd0bc

vim-patch:8.2.3030: Coverity reports a memory leak

Problem:    Coverity reports a memory leak.
Solution:   Fix the leak and a few typos. (Dominique Pellé, closes vim/vim#8418)
vim/vim@cb54bc6

Patch v8.2.3022 is mostly N/A but cannot be included here
because of new feature check for "has()".

vim-patch:8.2.3032: build problems with MSVC, other crypt issues with libsodium

Problem:    Build problems with MSVC, other crypt issues with libsodium.
Solution:   Adjust MSVC makefile. Disable swap file only when 'key' is set.
            Adjust error message used when key is wrong.  Fix Coverity issues.
            (Christian Brabandt, closes vim/vim#8420, closes vim/vim#8411)
vim/vim@226b28b

vim-patch:8.2.3044: Amiga MorphOS and AROS: process ID is not valid

Problem:    Amiga MorphOS and AROS: process ID is not valid.
Solution:   Use FindTask to return something which is unique to all processes.
            (Ola Söder, closes vim/vim#8444)
vim/vim@3a62b14

vim-patch:8.2.3046: Amiga MorphOS: Term mode is set using DOS packets

Problem:    Amiga MorphOS: Term mode is set using DOS packets.
Solution:   Use the same way of setting term mdoe on all next gen Amiga-like
            systems.  (Ola Söder, closes vim/vim#8445)
vim/vim@b420ac9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants