Skip to content

Indentation not made after a function parameter list with a type hint #1461

Closed

Description

Actual behavior

example

Expected behavior

The cursor to indent after hitting Enter.

Steps to reproduce:

def foo(x: int):

Activity

  1. DonJayamanne commented on Apr 26, 2018

    @DonJayamanne

    Time to start writing unit tests for this.

  2. DonJayamanne commented on Apr 26, 2018

    @DonJayamanne

    Here's what we have today:

    {
        beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except)\b.*:\s*\S+/,
        action: { indentAction: IndentAction.None }
    },
    {
        beforeText: /^\s*(?:def|class|for|if|elif|else|while|try|with|finally|except|async)\b.*?:\s*/,
        action: { indentAction: IndentAction.Indent }
    },
    {
        beforeText: /^\s+(continue|break|return)\b.*/,
        afterText: /\s+$/,
        action: { indentAction: IndentAction.Outdent }
    }

    If we have the python code def foo(x: int):, then indentation breaks, even if we were to fix the second rule.

    I'd like to ensure we have covered all possible scenarios in this issue that can be used as test cases for each of the rules. Unfortunately we don't have any tests for these rules and I'm not comfortable making changes to this.

    Time to start hunting down all issues related to indentation and prepare a list of test cases/issues.

  3. nottoseethesun commented on May 10, 2018

    @nottoseethesun

    Is this unrelated to microsoft/monaco-editor#612 ?

  4. DonJayamanne commented on May 24, 2018

    @DonJayamanne

    This seems to be caused by the implementation of editor.formatOnType

  5. locked as resolved and limited conversation to collaborators on Jul 10, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-formattingbugIssue identified by VS Code Team member as probable bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions