porcupine icon indicating copy to clipboard operation
porcupine copied to clipboard

Edited the google search plugin to include multi line searches

Open thealmightychuck opened this issue 2 years ago • 5 comments

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

thealmightychuck avatar Dec 01 '23 03:12 thealmightychuck

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 :)

Akuli avatar Dec 01 '23 11:12 Akuli

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.

thealmightychuck avatar Dec 01 '23 21:12 thealmightychuck

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.

Akuli avatar Dec 02 '23 20:12 Akuli

You can Google with newlines?

Moosems avatar Dec 03 '23 16:12 Moosems

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

rdbende avatar Dec 03 '23 17:12 rdbende