Repository: spyder-ide/spyder

Issue:
Keyboard shortcut for Find not working in Mac
<!--- **PLEASE READ:** When submitting here, please ensure you've completed the following checklist and checked the boxes to confirm. Issue reports without it may be closed. Thanks! --->

### Issue Report Checklist

* [Y ] Searched the [issues page](https://github.com/spyder-ide/spyder/issues?q=is%3Aissue) for similar reports
* [Y ] Read the relevant sections of the [Spyder Troubleshooting Guide](https://github.com/spyder-ide/spyder/wiki/Troubleshooting-Guide-and-FAQ) and followed its advice
* [Y] Reproduced the issue after updating with ``conda update spyder`` (or ``pip``, if not using Anaconda)
* [ ] Could not reproduce inside ``jupyter qtconsole`` (if console-related)
* [Y ] Tried basic troubleshooting (if a bug/error)
    * [Y ] Restarted Spyder
    * [Y ] Reset preferences with ``spyder --reset``
    * [N ] Reinstalled the latest version of [Anaconda](https://www.anaconda.com/download/)
    * [Y ] Tried the other applicable steps from the Troubleshooting Guide
* [ ] Completed the **Problem Description**, **Steps to Reproduce** and **Version** sections below


## Problem Description

Tried to change keyboard shortcut for "Find Next" from F3 to command-G.  Preferences shows that the change has been made, but pressing command-G has no effect.  I can't test to see if F3 works, as F3 is mapped to another function on my computer.

![image](https://user-images.githubusercontent.com/26334076/116171125-2c37d200-a6d6-11eb-824b-a46baa16bb20.png)


### What steps reproduce the problem?

1. Changed "Find Next" from F3 to Command-G
2. 
3. 

### What is the expected output? What do you see instead?

I expect to see the next matching item highlighted in the text editor

### Paste Traceback/Error Below (if applicable)
<!--- Copy from error dialog or View > Panes > Internal Console --->

```python-traceback

PASTE TRACEBACK HERE

```

## Versions
<!--- You can get this information from Help > About Spyder...
or (if Spyder won't launch) the "conda list" command
from the Anaconda Prompt/Terminal/command line. --->

* Spyder version:  3.74
* Python version: 5.0
* Qt version: 5.9.7
* PyQt version: 5.9.2
* Operating System name/version: OSX 10.15.7
* +

### Dependencies
<!--- Please go to the menu entry Help > Dependencies,
press the Copy to clipboard button and paste below --->

```
PASTE DEPENDENCIES HERE
```

# Mandatory:
applaunchservices >=0.1.7     :  0.2.1 (OK)
atomicwrites >=1.2.0          :  1.4.0 (OK)
chardet >=2.0.0               :  4.0.0 (OK)
cloudpickle >=0.5.0           :  1.6.0 (OK)
cookiecutter >=1.6.0          :  1.7.2 (OK)
diff_match_patch >=20181111   :  20200713 (OK)
intervaltree >=3.0.2          :  3.1.0 (OK)
IPython >=7.6.0               :  7.22.0 (OK)
jedi =0.17.2                  :  0.17.2 (OK)
jsonschema >=3.2.0            :  3.2.0 (OK)
keyring >=17.0.0              :  22.3.0 (OK)
nbconvert >=4.0               :  6.0.7 (OK)
numpydoc >=0.6.0              :  1.1.0 (OK)
parso =0.7.0                  :  0.7.0 (OK)
pexpect >=4.4.0               :  4.8.0 (OK)
pickleshare >=0.4             :  0.7.5 (OK)
psutil >=5.3                  :  5.8.0 (OK)
pygments >=2.0                :  2.8.1 (OK)
pylint >=1.0                  :  2.7.4 (OK)
pyls >=0.36.2;<1.0.0          :  0.36.2 (OK)
pyls_black >=0.4.6            :  0.4.6 (OK)
pyls_spyder >=0.3.2           :  0.3.2 (OK)
qdarkstyle =3.0.2             :  3.0.2 (OK)
qstylizer >=0.1.10            :  0.1.10 (OK)
qtawesome >=0.5.7             :  1.0.2 (OK)
qtconsole >=5.0.3             :  5.0.3 (OK)
qtpy >=1.5.0                  :  1.9.0 (OK)
rtree >=0.8.3                 :  0.9.7 (OK)
setuptools >=39.0.0           :  52.0.0.post20210125 (OK)
sphinx >=0.6.6                :  3.5.3 (OK)
spyder_kernels >=2.0.1;<2.1.0 :  2.0.1 (OK)
textdistance >=4.2.0          :  4.2.1 (OK)
three_merge >=0.1.1           :  0.1.1 (OK)
watchdog >=0.10.3;<2.0.0      :  1.0.2 (OK)
zmq >=17                      :  20.0.0 (OK)

# Optional:
cython >=0.21                 :  0.29.23 (OK)
matplotlib >=2.0.0            :  3.3.4 (OK)
numpy >=1.7                   :  1.18.1 (OK)
pandas >=1.1.1                :  1.2.4 (OK)
scipy >=0.17.0                :  1.6.2 (OK)
sympy >=0.7.3                 :  1.8 (OK)


Discussion:
Hi @mpeters2,

I was unable to reproduce your issue, are you using the shortcut once the find replace widget is opened? 
@ steff456 

Yes, I'm using it once the widget is opened.  After playing around with it some more, I can get it to work the first time I type something in the "find" box. Having said that, it:  if there are three or more matches, pressing the short cut will highlight the second match, but will not highlight the next matches.  After finding the first match, it simply doesn't seem to work any more (see screen shot below where it is stuck on the second match of "def"; the "search" menu is open to confirm that command-G has been mapped to "find next", but this result was produced by using the keyboard shortcut).

On the other hand, the "find next" down-arrow in the find widget works just fine, as does "Find Next" in the pull-down menu, so it seems to be a mapping from the keyboard to the behavior that is wonky.

![image](https://user-images.githubusercontent.com/26334076/116286468-42d53c00-a75d-11eb-85c8-599a2206492d.png)


> After finding the first match, it simply doesn't seem to work any more (see screen shot below where it is stuck on the second match of "def"; the "search" menu is open to confirm that command-G has been mapped to "find next", but this result was produced by using the keyboard shortcut)

I think this is caused because the focus changes from find/replace widget (where you introduce the text to search for) to the editor. Could you check that?
if I click in the text editor, the word in the search box (e.g. "def") is highlighted in gray in the source code, but command-G doesn't do anything.  If I click in the search box, then one of the search terms is highlighted in light blue and the rest in gray (as in the picture post above), but command-G still doesn't do anything.

Clicking on the up and down arrow (find next and find previous) works just fine.  I even tried command-G after click the arrows, and it still doesn't work.
While I cannot reproduce the OP, I'm having an issue that may be related.
The default shortcut for "run cell" (editor context) is control-return, but this is executed even when the IPython Console has focus, which is a problem because control-return in the Console should create a new line without execution.
Additionally, the "run cell and advance" shortcut (editor context) is shift-return and does not work at all.
> The default shortcut for "run cell" (editor context) is control-return, but this is executed even when the IPython Console has focus, which is a problem because control-return in the Console should create a new line without execution.

I think `Ctrl+Return` is a global shortcut, i.e. it works for whichever pane the focus is given to.

> Additionally, the "run cell and advance" shortcut (editor context) is shift-return and does not work at all.

This is weird.
> I think `Ctrl+Return` is a global shortcut, i.e. it works for whichever pane the focus is given to.

Okay, that makes sense.

Okay, looks like all is good. As @ccordoba12 mentioned, the "run cell" and "run cell and advance" actions are also global (they reside in the Run menu). When changing these shortcuts in Spyder preferences, it is insufficient to Apply the changes or exit the preference pane; Spyder must be restarted for the Run menu to update. I modified "run cell" so as not to conflict with the IPython Console newline behavior and after restart all shortcuts work as expected, including `Shift+Return` to "run cell and advance".

@mpeters2, after modifying the "Find next" shortcut, did you try restarting Spyder? It worked for me _without_ restarting Spyder, but maybe that would fix it for you.
Sorry for the 11-month reply, but I still have this issue on one of my computers: an Intel iMac running Spyder 5.3.  My M1 MacBook running Spyder 5.15 does not have the keyboard mapping issue.
update: Since it is the same machine, but different versions of Spyder, that was giving me grief, I had a hunch that it was a corrupted preferences that was affecting each version of Spyder.  So I reset the keymappings to their default, and then redid the keymappings.  Now everything seems to work.
Great news @mpeters2! Closing this issue then.
I take it back: that fix only worked for a short while.  I came back to my computer the next morning and command-G no longer worked. I had to reset the keyboard mappings and remap command-G for Find Again.

I've got a great idea: instead of using Windows bindings, why not use Mac-native bindings?  You already use it for Find and Replace, you just need to hard-wire it for Find Again.
Ok, that's a good idea. We'll take a look at it for our next release (5.3.2).
@mrclary, could you take a look at this one?

Resolving patch:
diff --git a/spyder/config/main.py b/spyder/config/main.py
--- a/spyder/config/main.py
+++ b/spyder/config/main.py
@@ -400,13 +400,14 @@
               '_/switch to variable_explorer': "Ctrl+Shift+V",
               '_/switch to find_in_files': "Ctrl+Shift+F",
               '_/switch to explorer': "Ctrl+Shift+X",
-              '_/switch to plots': "Ctrl+Shift+G",
+              '_/switch to plots': "Ctrl+Shift+J" if MAC else "Ctrl+Shift+G",
               '_/switch to pylint': "Ctrl+Shift+C",
               '_/switch to profiler': "Ctrl+Shift+R",
               # -- In widgets/findreplace.py
               'find_replace/find text': "Ctrl+F",
-              'find_replace/find next': "F3",
-              'find_replace/find previous': "Shift+F3",
+              'find_replace/find next': "Ctrl+G" if MAC else "F3",
+              'find_replace/find previous': (
+                  "Ctrl+Shift+G" if MAC else "Shift+F3"),
               'find_replace/replace text': "Ctrl+R",
               'find_replace/hide find and replace': "Escape",
               # ---- Editor ----
@@ -424,7 +425,7 @@
               'editor/move line up': "Alt+Up",
               'editor/move line down': "Alt+Down",
               'editor/go to new line': "Ctrl+Shift+Return",
-              'editor/go to definition': "Ctrl+G",
+              'editor/go to definition': "F3" if MAC else "Ctrl+G",
               'editor/toggle comment': "Ctrl+1",
               'editor/blockcomment': "Ctrl+4",
               'editor/unblockcomment': "Ctrl+5",
@@ -639,4 +640,4 @@
 #    or if you want to *rename* options, then you need to do a MAJOR update in
 #    version, e.g. from 3.0.0 to 4.0.0
 # 3. You don't need to touch this value if you're just adding a new option
-CONF_VERSION = '71.0.0'
+CONF_VERSION = '71.1.0'


Test patch: