spyder-ide / spyder

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

Undesirable removal of outer brackets when removing inner brackets #21702

Open Chuck321123 opened 8 months ago

Chuck321123 commented 8 months ago

Issue Report Checklist

Checklist checked

Problem Description

So this problem is a bit hard to explain so i recorded the problem. If you have inner brackets next to an outer layer of brackets and remove the inner brackets, the removal of the last inner bracket will cancel out with the outer bracket where you remove two brackets with the backspace instead of 1. This also holds true for paratheses and curvy brackets. A solution will of course be to just remove 1 bracket at a time with the backspace in this scenario.

What steps reproduce the problem?

https://github.com/spyder-ide/spyder/assets/123987501/18509bfb-4ff4-4815-81be-1f77878d226a

What is the expected output?

That it doesnt remove both of the brackets in the last move

Versions

Dependencies

# Mandatory:
atomicwrites >=1.2.0             :  1.4.0 (OK)
chardet >=2.0.0                  :  4.0.0 (OK)
cloudpickle >=0.5.0              :  2.2.1 (OK)
cookiecutter >=1.6.0             :  1.7.3 (OK)
diff_match_patch >=20181111      :  20200713 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.15.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.18.1 (OK)
jellyfish >=0.7                  :  1.0.1 (OK)
jsonschema >=3.2.0               :  4.19.2 (OK)
keyring >=17.0.0                 :  24.3.0 (OK)
nbconvert >=4.0                  :  7.10.0 (OK)
numpydoc >=0.6.0                 :  1.5.0 (OK)
paramiko >=2.4.0                 :  2.8.1 (OK)
parso >=0.7.0,<0.9.0             :  0.8.3 (OK)
pexpect >=4.4.0                  :  4.8.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  5.9.0 (OK)
pygments >=2.0                   :  2.15.1 (OK)
pylint >=2.5.0,<3.1              :  2.16.2 (OK)
pylint_venv >=3.0.2              :  3.0.3 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.9.0,<1.10.0            :  1.9.0 (OK)
pylsp_black >=1.2.0,<3.0.0       :  2.0.0 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.2 (OK)
qtawesome >=1.2.1                :  1.2.2 (OK)
qtconsole >=5.5.0,<5.6.0         :  5.5.1 (OK)
qtpy >=2.1.0                     :  2.4.1 (OK)
rtree >=0.9.7                    :  1.0.1 (OK)
setuptools >=49.6.0              :  68.2.2 (OK)
sphinx >=0.6.6                   :  5.0.2 (OK)
spyder_kernels >=2.5.0,<2.6.0    :  2.5.0 (OK)
textdistance >=4.2.0             :  4.2.1 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  2.1.6 (OK)
zmq >=22.1.0                     :  25.1.0 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  3.8.2 (OK)
numpy >=1.7                      :  1.26.3 (OK)
pandas >=1.1.1                   :  2.1.4 (OK)
scipy >=0.17.0                   :  1.11.4 (OK)
sympy >=0.7.3                    :  None (NOK)
GitKia1392 commented 8 months ago

That it doesnt remove both of the brackets in the last move

Yo @Chuck321123, That's really weird; Can you tell me what things you tried - I'd recommend starting with the basics like doing a --reset and maybe a reinstall or do goto Tools --> Reset Spyder to factory defaults if you don't wanna do and full reinstall or a line command such as --reset as mentioned earlier.

Thanks

Chuck321123 commented 8 months ago

@GitKia1392 I have tried that as well, but as far as I can remember, this probem has existed since day 1 of installing Spyder. This problem also occurs in Linux Ubuntu

jitseniesen commented 8 months ago

Hi @Chuck321123, thanks for the clear report. It's quite easy to reproduce the behaviour your reported, and I agree that is it is not desirable. The more difficult issue is, how can Spyder easily decide whether it should delete both brackets or only one?

I don't know exactly why this feature was introduced, but one situation in which Spyder probably should probably delete both brackets is you type on an empty line: f ( BACKSPACE. After the (, Spyder automatically inserts the closing parenthesis so the line now shows f() with the cursor between the parentheses. I think it makes sense for Spyder to then delete both parenthesis after the backspace, so that the backspace undoes what the ( keypress added before.

GitKia1392 commented 8 months ago

It might also be the Windows or Ubuntu OSes issue as maybe your PC/laptop might've ran into a problem while trying to delete the last ); If you have Ubuntu I'd say it might be compatibility issue, It might be even be the Python. I personally think its the cause of Spyder trying to like auto help u like as in where u do ) it auto makes it (), so it might be as well be considered for this.

For @jitseniesen, I'd recommend to leave this issue open for future users who might occur this issue.

Thanks