nvim-pack / nvim-spectre

Find the enemy and replace them with dark power.
MIT License
1.91k stars 67 forks source link

show line number for each result text #199

Closed BarretRen closed 4 months ago

BarretRen commented 6 months ago

Hi, this plugin is so wonderful and I use it everyday. And I found an bug (if we can call it a bug) for the line number, the pull request is used to fix it.

During the search, if there are more than one result found in the same file, we can only see the the line/column numbers of the first matched result showing behand the filename. Here is an examle: image

I think it is useless, because we still can't know the line number of each matched result. The following formats is more useful. we can see which file the results belong to, and we can also know the line number of each result. image

This pull request is used to show the new formats, please help to check it.

BarretRen commented 5 months ago

After such a long time, nothing happens. So, close this. Fuck that.

EpsilonKu commented 4 months ago

Sorry, I couldn't test this. Will do today

EpsilonKu commented 4 months ago

Screenshot from 2024-02-05 16 53 30 Well, the highlight is moved to left. https://github.com/nvim-pack/nvim-spectre/blob/817944747413ead7438ec28334201a340898b7e6/lua/spectre/ui.lua#L31-L33 Add to this line length of line text_opts.item_line so it compensate highlight to move right. Also add in https://github.com/nvim-pack/nvim-spectre/blob/817944747413ead7438ec28334201a340898b7e6/lua/spectre/ui.lua#L36-L38

EpsilonKu commented 4 months ago

If you busy, I can add myself. Sorry, for late reply. I was busy.

BarretRen commented 4 months ago

Thanks for reopen this pull request and very sorry about my rude words before. I have rebased the changes with the master branch and added a new changeset to fix the highlight issue. It seems ok on my server, here is the test result: image

I didn't notice the highlight before and forget to check this. Sorry about that and sorry about my rude words in previous comment again.

EpsilonKu commented 4 months ago

There is another 3 call in init.lua which calls render_line. Can you add them also item_line? I got error when typed replace word because it calls another render_line.

EpsilonKu commented 4 months ago

Sorry about that and sorry about my rude words in previous comment again.

It helped me finally look for this project again. Thank you, lol.

BarretRen commented 4 months ago

There is another 3 call in init.lua which calls render_line. Can you add them also item_line? I got error when typed replace word because it calls another render_line.

new changeset is pushed, please help to check it.

EpsilonKu commented 4 months ago

Well, it fails test because text doesn't match up because of number row. Can you add option to disable it and enable it by default. I will disable on tests later. So if it done, pretty much ready for MR.

BarretRen commented 4 months ago

new option lnum_for_results is added:

lnum_for_results   = true, -- show line number for search/replace results
EpsilonKu commented 4 months ago

LGTM