spyder-ide / spyder

Official repository for Spyder - The Scientific Python Development Environment
https://www.spyder-ide.org
MIT License
8.33k stars 1.61k forks source link

Changing "Toggle comment" keyboard shortcut to "CTRL+R" doesn't work #14777

Open kaare-mikkelsen opened 3 years ago

kaare-mikkelsen commented 3 years ago

Issue Report Checklist

Problem Description

when I go into tools -> preferences -> keyboard shortcuts, and change 'toggle comment' to 'CTRL+R', that doesn't work. After I change the shortcut to CTRL+R, CTRL+1 stop's working (as it should). But not nothing happens when I press CTRL+R. When I change the shortcut back to CTRL+1, that works again as expected.

Versions

Dependencies


# Mandatory:
atomicwrites >=1.2.0           :  1.4.0 (OK)
chardet >=2.0.0                :  3.0.4 (OK)
cloudpickle >=0.5.0            :  1.6.0 (OK)
diff_match_patch >=20181111    :  20200713 (OK)
intervaltree                   :  None (OK)
IPython >=4.0                  :  7.19.0 (OK)
jedi =0.17.1                   :  0.17.1 (OK)
nbconvert >=4.0                :  6.0.7 (OK)
numpydoc >=0.6.0               :  1.1.0 (OK)
paramiko >=2.4.0               :  2.7.2 (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.7.2 (OK)
pygments >=2.0                 :  2.7.2 (OK)
pylint >=1.0                   :  2.6.0 (OK)
pyls >=0.34.0;<1.0.0           :  0.35.1 (OK)
qdarkstyle >=2.8               :  2.8.1 (OK)
qtawesome >=0.5.7              :  1.0.1 (OK)
qtconsole >=4.6.0              :  4.7.7 (OK)
qtpy >=1.5.0                   :  1.9.0 (OK)
rtree >=0.8.3                  :  0.9.4 (OK)
sphinx >=0.6.6                 :  3.2.1 (OK)
spyder_kernels >=1.9.4;<1.10.0 :  1.9.4 (OK)
watchdog                       :  None (OK)
zmq >=17                       :  19.0.2 (OK)

# Optional:
cython >=0.21                  :  0.29.21 (OK)
matplotlib >=2.0.0             :  3.3.2 (OK)
numpy >=1.7                    :  1.19.2 (OK)
pandas >=0.13.1                :  1.1.3 (OK)
scipy >=0.17.0                 :  1.5.2 (OK)
sympy >=0.7.3                  :  1.6.2 (OK)
ccordoba12 commented 3 years ago

Hey @kaare-mikkelsen, thanks for reporting. Please update Spyder to see if that helps. You can do that by closing Spyder, opening the Anaconda Prompt and running there

conda update anaconda
conda install spyder=4.2.1

Let us know if that helps.

kaare-mikkelsen commented 3 years ago

I ran:

conda update anaconda conda install spyder=4.2.1

In conda prompt.

It ran for a very long time, and ended up listing a lot of conflicts. After finishing, spyder is still not upgraded. Unfortunately, I closed the prompt, so I do not have the (very long) list of apparent conflicts.

do you need me to run it again?

ccordoba12 commented 3 years ago

I think you need to reinstall Anaconda and run again

conda update anaconda
conda install spyder=4.2.1

Please see the second part of our video to learn how to do that properly.

kaare-mikkelsen commented 3 years ago

hi again :)

this worked, in regards to updating spyder. it is now version 4.2.1

however, this has not changed my issue with changing 'toggle comment'. For comparison, I just tried changing 'run' from f5 to ctrl+R, and that worked fine. so it seems to be the commenting in particular?

ccordoba12 commented 3 years ago

Ok, thanks for updating Spyder and confirming that our latest version doesn't fix the problem. We'll take a look at this in a future release.

TeunBartelds commented 2 years ago

Just switched to Spyder today and found the same bug where key bindings for (un)commenting to Ctrl+R do not work. I wonder if it has to do with the 'editor' context (since e.g. the run command can be succesfully binded tot Ctrl+R).

If you could give me some pointers as to where to look in the source code, I'm happy to attempt to find the root cause myself.

dalthviz commented 2 years ago

Hi @TeunBartelds I think there is an undetected conflict with the shortcut for the find_replace widget replace text action. If you change that shortcut too you will be able to bind Ctrl + R to be the editor toggle comment action

TeunBartelds commented 2 years ago

Thank you @dalthviz , this resolved the issue for me.

I guess the actual issue could then boil down to the fact that the context for find_replace should be changed to editor? Or at least their bindings should be mutually exclusive.

dalthviz commented 2 years ago

Glad the workaround is working for you @TeunBartelds ! I would say that yes, the bindings should be mutually exclusive and show a warning message for a found conflict (in fact any plugin that uses the find and replace widget should check for conflicts with the shortcuts set to it and their own shortcuts).

LizzyMcKay commented 9 months ago

This bug still exists for me:

Spyder 5.5.0 installed through mamba OS: Arch Linux 6.7.0 Python 3.11.5

The workaround by @dalthviz, however, works flawlessly.