Skip to content

'Reindent Lines' produces different indentation than 'Format Document' in TypeScript #32835

Closed

Description

@borekb
  • VSCode Version: Code 1.15.1 (41abd21, 2017-08-16T18:05:38.342Z), also in 1.16
  • OS Version: Windows_NT ia32 10.0.15063

Formatting via Format Document:

const MyReactComponent = (props) => {
    return (
        <div>
            <Helmet titleTemplate='%s'>
                <title>Hello</title>
            </Helmet>
        </div>
    );
};

Formatting via Reindent Lines:

const MyReactComponent = (props) => {
    return (
        <div>
        <Helmet titleTemplate='%s'>
        <title>Hello</title>
        </Helmet>
        </div>
    );
};

Another example; Format Document:

/**
 * Example
 */
function example() {
}

Reindent Lines:

/**
* Example
*/
function example() {   
}

Reindent Lines often gets it wrong, Format Document is much more reliable currently (but it does more than reindenting; I often want to just fix the indentation).

Activity

  1. added
    editor-autoindent
    on Aug 19, 2017
  2. borekb commented on Aug 19, 2017

    @borekb
    Author

    Oh, just found this issue: 'reindent all lines' removes leading space in comment #19142. This is probably a duplicate of it.

  3. borekb commented on Sep 15, 2017

    @borekb
    Author

    Another example:

    Formatting via Format Document:

    const MyReactComponent = (props) => {
        return (
            <div>
                <Helmet titleTemplate='%s'>
                    <title>Hello</title>
                </Helmet>
            </div>
        );
    };

    Formatting via Reindent Lines:

    const MyReactComponent = (props) => {
        return (
            <div>
            <Helmet titleTemplate='%s'>
            <title>Hello</title>
            </Helmet>
            </div>
        );
    };
  4. borekb commented on Sep 15, 2017

    @borekb
    Author

    I've updated the original post, this React example shows the issue better.

  5. added
    bug
    on Nov 16, 2017
  6. jonnysamps commented on Aug 22, 2018

    @jonnysamps

    Please fix. Love VSCode but this drives me nuts.

  7. rebornix commented on Sep 18, 2018

    @rebornix
    Contributor

    Let's track this issue in #19140 which is talking about the same thing. For now, you can set editor.autoIndent to false to avoid indentation adjustment and probably turn on formatting for tying or saving.

  8. rebornix commented on Sep 18, 2018

    @rebornix
    Contributor

    Borek Bernard (@borekb) your feedback and reproduce steps will be considered even this issue is closed.

  9. added
    *duplicate
    on Sep 18, 2018
  10. vscodebot commented on Sep 18, 2018

    @vscodebot

    Thanks for creating this issue! We figured it's covering the same as another one we already have. Thus, we closed this one as a duplicate. You can search for existing issues here. See also our issue reporting guidelines.

    Happy Coding!

  11. locked and limited conversation to collaborators on Nov 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*duplicatebugeditor-autoindent

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions