konradsz / igrep

Interactive Grep
MIT License
641 stars 17 forks source link

Add a context viewer to see match context, and don't close igrep upon editor close #25

Closed Robertleoj closed 2 years ago

Robertleoj commented 2 years ago

I was about to start a new project that was like igrep, but with the context viewer - I started, and did some work, but then someone pointed out igrep.

It was exactly what I was thinking, except it was lacking the code viewer, and it closed upon editor close.

So I changed those two things, and now it's as I like it.

If you like it better this way too, then you can merge this. :)

konradsz commented 2 years ago

Hey @Robertleoj, thank you for your contribution, I very much like the idea of context viewer being introduced in igrep!

I think the user should be able to toggle the viewer on/off and for a time being I would do it opt-in rather than opt-out feature. Do you mind if I work further on your PR and refine an implementation a bit?

BTW. I highly recommend introducing rustfmt and clippy in your Rust workflow!

konradsz commented 2 years ago

Forgot to ask:

and it closed upon editor close

What editor do you use? This isn't expected behaviour, but I cannot observe it unfortunately.

Robertleoj commented 2 years ago

Hey @Robertleoj, thank you for your contribution, I very much like the idea of context viewer being introduced in igrep!

Great! :D

I think the user should be able to toggle the viewer on/off and for a time being I would do it opt-in rather than opt-out feature. Do you mind if I work further on your PR and refine an implementation a bit?

Yes, I was expecting that reply, along with mentions about the viewer not using the user's theme config. I just did not have time to implement these, so go nuts improving it :D One thing, my friends wanted the package with the viewer, so I published a seperate package for them, leaving the PR branch. After that I fixed a couple bugs in my implementation, They're trivial fixes, and I'll put them in here if you don't beat me to it. The bugs were:

BTW. I highly recommend introducing rustfmt and clippy in your Rust workflow!

Oh of course, sorry about that - I'm pretty new to using Rust, thanks for the tip!

What editor do you use? This isn't expected behaviour, but I cannot observe it unfortunately.

Oh ok, in the code it looked like that was intended behavior - I might have skimmed it too fast then. I'm using standard vim on ubuntu 22.04, and I'm using tilix as my terminal emulator if that matters.

Happy you like the contribution :D igrep is awesome, great work

Robertleoj commented 2 years ago

Just fixed the two bugs, and applied rustfmt and clippy. I knew about rustfmt, but not clippy - it's an awesome tool, thanks for pointing that out!

konradsz commented 2 years ago

I made some refactoring and merged your PR, thanks for a great idea! :) I reverted changes related to opening files since I believe it is working correctly. If you notice igrep closing upon editor close please file an issue with reproduction steps, I will try to take care of it. I will release a new version with this feature included soon after I make some required refactoring in a code base - it is messy in a few places.