Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncommenting adds an extra whitespace in some cases #14326

Closed
8 of 10 tasks
remisalmon opened this issue Nov 27, 2020 · 4 comments · Fixed by #14768
Closed
8 of 10 tasks

Uncommenting adds an extra whitespace in some cases #14326

remisalmon opened this issue Nov 27, 2020 · 4 comments · Fixed by #14768

Comments

@remisalmon
Copy link
Contributor

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

Commenting and uncommenting a line with an odd number of leading whitespace adds an extra space.

What steps reproduce the problem?

  1. Type
x = [1,
     2,
     3]
  1. Select all 3 lines, comment and uncomment
  2. The code is now
x = [1,
      2,
      3]

What is the expected output? What do you see instead?

The code after step 3 should be

x = [1,
     2,
     3]

If the number of leading whitespace is even, for ex:

xx = [1,
      2,
      3]

then there is no issue.

Versions

  • Spyder version: 4.2.0
  • Python version: 3.8.5
  • Qt version: 5.9.7
  • PyQt version: 5.9.2
  • Operating System name/version: Linux 5.9.10

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 >=3.0.2            :  3.0.2 (OK)
IPython >=4.0                   :  7.19.0 (OK)
jedi =0.17.2                    :  0.17.2 (OK)
jsonschema >=3.2.0              :  3.2.0 (OK)
keyring >=17.0.0                :  21.5.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.7.3 (OK)
pygments >=2.0                  :  2.7.2 (OK)
pylint >=1.0                    :  2.6.0 (OK)
pyls >=0.36.1;<1.0.0            :  0.36.1 (OK)
pyls_black >=0.4.6              :  0.4.6 (OK)
pyls_spyder >=0.1.1             :  0.2.1 (OK)
qdarkstyle >=2.8                :  2.8.1 (OK)
qtawesome >=0.5.7               :  1.0.1 (OK)
qtconsole >=4.7.7               :  5.0.1 (OK)
qtpy >=1.5.0                    :  1.9.0 (OK)
rtree >=0.8.3                   :  0.9.4 (OK)
setuptools >=39.0.0             :  50.3.1.post20201107 (OK)
sphinx >=0.6.6                  :  3.3.1 (OK)
spyder_kernels >=1.10.0;<1.11.0 :  1.10.0 (OK)
three_merge >=0.1.1             :  0.1.1 (OK)
watchdog >=0.10.3               :  0.10.4 (OK)
xdg >=0.26                      :  0.26 (OK)
zmq >=17                        :  20.0.0 (OK)

# Optional:
cython >=0.21                   :  None (NOK)
matplotlib >=2.0.0              :  None (NOK)
numpy >=1.7                     :  None (NOK)
pandas >=1.1.1                  :  None (NOK)
scipy >=0.17.0                  :  None (NOK)
sympy >=0.7.3                   :  None (NOK)
@steff456
Copy link
Member

Hi @remisalmon,

I could reproduce this issue, we will fix it for our future version of spyder.

Thanks for reporting!

@Mark531
Copy link

Mark531 commented Apr 13, 2021

Is there any chance for a fix soon? This bug persists in v5.0.0.

@remisalmon
Copy link
Contributor Author

@Mark531 I have opened at PR at #14768.

@cg-mayrhofer
Copy link

cg-mayrhofer commented Nov 7, 2022

Same here, this can be reproduced with tabs instead of whitespace as indent type. Toggle Comment adds a whitespace and when the line is indented, the space remains.
Using Spyder 5.3.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants