Editor - weird indentation
Okay, this is not really a bug but we might discuss whther o not it's a good feature.
The editor indents after a function definition, best explained by watching the accompanying video.
Comments (7)
-
-
Can this issue be closed?
-
I have found some further buggy paste and indentation behavior.
Let’s assume to have such code:
from itom import dataObject """This is a docstring with some lines of stupid code examples"""
- Then mark and copy the whole docstring
- Then !! mark the first line from left to right !! and paste the docstring
The result looks than like:
"""This is a docstring with some lines of stupid code examples""" """This is a docstring with some lines of stupid code examples"""
-
There is some similar indentation behavior when your text in the clipboard contains a newline as the first characters and you paste it not at the first position of line.
Result looks than like:
from itom import addButton from itom import removeButton # some comment
-
fixes an issue about the correction of the indentation level when pasting a text to a script (see issue 165)
→ <<cset a445a50e16ea>>
-
The initial reason for this issue will not be fixed, since it is a feature and can be disabled by a property in the itom property dialog.
Johann’s comment about pasting the “this is a docstring…” multiline comment is fixed in commit https://bitbucket.org/itom/itom/commits/a445a50e16eae6b2040cbe8c55e7e93be35cc5eb
-
- changed status to resolved
Issue resolved.
- Log in to comment
Hello,
this behaviour is new in itom 4.1 and has been implemented to support the standard Python coding style guidelines from PEP8.
PEP8 proposes, that lines should not contain any trailing whitespaces or tabs, hence, “empty” lines must not be indented.
In order to support this, itom removes trailing whitespaces from the current line as soon as the Return key is pressed to
create a new line. This feature has been added in order to support common auto code formatting tools like black, yapf or autopep8,
which where also introduced with itom 4.1. Once one of these tools is used with default parameters, all trailing whitespaces in all
lines are automatically removed, too. However, this removal does not change the block of a definition, such that the code folds in
the left margin still displays the correct outline of a method.
Other IDEs like Visual Studio Code or Spyder have the same behaviour.
However: You can disable this feature by a checkbox in the itom property dialog (tab Editor >> General, Group “Indentation”):
At first, I also had concerns to implement this feature, however there are many advantes to allow black, yapf, autopep8 among others
to let a script auto format. And if these tools should be used (especially black, that does not provide any parameterization), it makes
sense to also implement the auto-removal of trailing whitespaces.
Cheers
Marc