Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

show line number for each result text #199

Merged
merged 3 commits into from
Feb 7, 2024
Merged

show line number for each result text #199

merged 3 commits into from
Feb 7, 2024

Conversation

BarretRen
Copy link

@BarretRen BarretRen commented Dec 27, 2023

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
Copy link
Author

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

@BarretRen BarretRen closed this Feb 1, 2024
@EpsilonKu
Copy link
Member

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

@EpsilonKu EpsilonKu reopened this Feb 5, 2024
@EpsilonKu
Copy link
Member

EpsilonKu commented Feb 5, 2024

Screenshot from 2024-02-05 16 53 30
Well, the highlight is moved to left.

api.nvim_buf_add_highlight(bufnr, namespace,
cfg.highlight.search,
text_opts.lnum, value[1] + view_opts.padding, value[2] + view_opts.padding)

Add to this line length of line text_opts.item_line so it compensate highlight to move right.
Also add in
api.nvim_buf_add_highlight(bufnr, namespace,
cfg.highlight.replace,
text_opts.lnum, value[1] + view_opts.padding, value[2] + view_opts.padding)

@EpsilonKu
Copy link
Member

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

@BarretRen
Copy link
Author

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
Copy link
Member

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
Copy link
Member

EpsilonKu commented Feb 6, 2024

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
Copy link
Author

BarretRen commented Feb 6, 2024

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
Copy link
Member

EpsilonKu commented Feb 6, 2024

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
Copy link
Author

new option lnum_for_results is added:

lnum_for_results   = true, -- show line number for search/replace results

@EpsilonKu
Copy link
Member

LGTM

@EpsilonKu EpsilonKu merged commit 6a0785e into nvim-pack:master Feb 7, 2024
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.

2 participants