Akuli / porcupine

A decent editor written in tkinter
MIT License
144 stars 46 forks source link

Edited the google search plugin to include multi line searches #1428

Open ChuckM2196 opened 7 months ago

ChuckM2196 commented 7 months ago

Just starting to learn to contribute to other projects. So I have no idea if I'm doing this correctly. Fixes #1427 - Fixed the issue of now allowing google searches with multiple lines selected Edited line 19 in plugins/google_search.py to include an additional conditional with multiple lines

Akuli commented 7 months ago

Thanks for working on this!

As I wrote in the issue, you probably don't want to actually google multiple lines. For example, let's say someone selects all text in the whole file, right-click, and accidentally click the googling button. We don't want to send a google search that is hundreds of lines long.

A better fix would be to modify the add_rightclick_option() function, so that there's some way to disallow multiple lines. For example, it could look like this:

    rightclick_menu.add_rightclick_option(
        "Search selected text on Google", google_search, needs_selected_text_single_line=True
    )

where needs_selected_text_single_line=True would be a new parameter that you would add to the function.

This will need several things to be changed in rightclick_menu.py. Let me know if you need help :)

ChuckM2196 commented 7 months ago

So we could still have the feature if someone wanted it, but have it optional and set it to disabled by default? I'll look into rightclick_menu.py to see what would need to be changed.

Akuli commented 7 months ago

I don't think anyone wants to google multiple lines at once. We can change it later if someone actually makes an issue and asks for it.

Moosems commented 7 months ago

You can Google with newlines?

rdbende commented 7 months ago

Google will replace it with a space, but yes, this is a completely valid search query: https://www.google.com/search?q=foo%0Abar