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

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

Closed
brettcannon opened this issue Apr 24, 2018 · 4 comments · Fixed by #1814
Closed

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

brettcannon opened this issue Apr 24, 2018 · 4 comments · Fixed by #1814
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@brettcannon
Copy link
Member

Actual behavior

example

Expected behavior

The cursor to indent after hitting Enter.

Steps to reproduce:

def foo(x: int):
@brettcannon brettcannon added bug Issue identified by VS Code Team member as probable bug needs PR area-formatting labels Apr 24, 2018
@brettcannon brettcannon added this to the April 2018 milestone Apr 24, 2018
@DonJayamanne
Copy link

Time to start writing unit tests for this.

@DonJayamanne
Copy link

DonJayamanne commented Apr 26, 2018

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.

@brettcannon brettcannon modified the milestones: April 2018, May 2018 May 2, 2018
@nottoseethesun
Copy link

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

@DonJayamanne
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-formatting bug Issue identified by VS Code Team member as probable bug
Projects
None yet
3 participants