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

Indentations mess up with comments #14909

Closed
rossbutler2000 opened this issue Mar 11, 2021 · 7 comments
Closed

Indentations mess up with comments #14909

rossbutler2000 opened this issue Mar 11, 2021 · 7 comments
Assignees

Comments

@rossbutler2000
Copy link

Description

What steps will reproduce the problem?

Almost everytime I comment out a section of code (using 'ctrl 1' on a highlighted block) and then uncomment it using the same process it messes with the indentation. I get errors on almost all lines of code and when I go to delete and retab, it often gives it a space or doesnt delete at all. It is incredibly frustrating and I have no idea why it happens. It forces me painstakenly go through all lines of effected code and change it or restart the entire script from scratch.

Versions

  • Spyder version: 4.2.3
  • Python version: 3.7.6
  • Qt version: 5.9.6
  • PyQt5 version: 5.9.2
  • Operating System: Linux 5.4.0-65-generic

Dependencies


# Mandatory:
atomicwrites >=1.2.0            :  1.4.0 (OK)
chardet >=2.0.0                 :  4.0.0 (OK)
cloudpickle >=0.5.0             :  1.6.0 (OK)
diff_match_patch >=20181111     :  20200713 (OK)
intervaltree >=3.0.2            :  3.1.0 (OK)
IPython >=7.6.0                 :  7.21.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.2 (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 >=2.8                :  2.8.1 (OK)
qtawesome >=0.5.7               :  1.0.1 (OK)
qtconsole >=5.0.1               :  5.0.2 (OK)
qtpy >=1.5.0                    :  1.9.0 (OK)
rtree >=0.8.3                   :  0.9.4 (OK)
setuptools >=39.0.0             :  52.0.0.post20210125 (OK)
sphinx >=0.6.6                  :  3.5.2 (OK)
spyder_kernels >=1.10.2;<1.11.0 :  1.10.2 (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)
xdg >=0.26                      :  0.27 (OK)
zmq >=17                        :  20.0.0 (OK)

# Optional:
cython >=0.21                   :  0.29.22 (OK)
matplotlib >=2.0.0              :  3.3.4 (OK)
numpy >=1.7                     :  1.19.2 (OK)
pandas >=1.1.1                  :  1.2.3 (OK)
scipy >=0.17.0                  :  1.6.1 (OK)
sympy >=0.7.3                   :  1.7.1 (OK)
@dalthviz
Copy link
Member

Hi @rossbutler2000 sorry to hear that, could you provide a code snippet/example code that triggers this error. Any info that allows to reproduce this is greatly appreciated

@remisalmon
Copy link
Contributor

Possible duplicate of #14326

@dalthviz
Copy link
Member

Hi @remisalmon I think you are right 👍 but just in case, @rossbutler2000 is your issue like the one in #14326? Let us know :)

@rossbutler2000
Copy link
Author

@dalthviz Yes I would say my problem looks very similar to #14326. However, I think mine extends further because sometimes when I am trying to fix it I will use the delete key and instead of deleting the whitespaces it will move the code to the right as if I am tabbing. And then if I go further sometimes it won't let me delete at all unless I select that line and the line above and delete.

A long while ago I messed with my setting so that when I tab it would use a tab instead of the default number of whitespaces. I'm not sure if that contributes to the problem or not but I thought I would let you know as well.

@dalthviz
Copy link
Member

Thanks for the feedback @rossbutler2000! and yep seems like because of your preferences regarding the tab vs white spaces, the behavior you're experiencing gets a little bit more strange/misliding :/

I think maybe you can check your preferences regarding the tabs and see if changing them helps a little bit (at least to make the fixing after removing comments a little bit less troublesome). For that you can check in the preference dialog under Editor > Source code:

image

Or if you don't have any important preference set you can try resetting Spyder preferences with the reset to defaults button to check if the default preferences work better (regarding the tab in your case).

Anyhow, I think this is mainly caused due the do/undo comments functionality so I will close this one. However, @rossbutler2000, if you have further comments or examples that you want to show us please put them in #14326 Let us know if changing your preferences regarding tabs helps a little bit :)

@Mark531
Copy link

Mark531 commented Apr 13, 2021

Even if the tabulation is defined as the indentation character, the "uncomment" function inserts a white space instead of '#' which triggers some indentation errors. This bug should be reopened.

@dalthviz
Copy link
Member

dalthviz commented Apr 14, 2021

Hi @Mark531 as stayed in a previous comment this was closed as duplicate of #14326 which I think matches quite well the description you are giving. If you want to provide more info regarding that please do it over #14326 thanks :)

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

No branches or pull requests

5 participants