Editor - weird indentation

Issue #165 resolved
Former user created an issue

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)

  1. M. Gronle

    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

  2. Johann Krauter

    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"""
    

  3. Johann Krauter

    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
    

  4. Log in to comment