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

Unify indentation and formatting APIs #34621

Open
borekb opened this issue Sep 19, 2017 · 0 comments
Open

Unify indentation and formatting APIs #34621

borekb opened this issue Sep 19, 2017 · 0 comments
Assignees
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach
Milestone

Comments

@borekb
Copy link

borekb commented Sep 19, 2017

Maybe this is wishful thinking but I am experiencing many subtle issues with the relatively new editor.autoIndent feature. It's a very useful one and I want to keep it but it misbehaves quite frequently, see e.g. issues #29390, #32333 and many others. Quite a good example is this (from #32835):

Indentation 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>
    );
};

It often seems to me that formatting API produces better results than indentation rules but even if that wasn't always the case it just seems logical to have a single API to power both features. It seems like this to me:

  1. Indenting functionality cares about the leading whitespaces.
  2. Formatting cares about the above plus anything after the first non-whitespace character.

So it's a subset / superset problem and I don't think it should be implemented twice, in a completely different manner. What do you think? Would there be a chance to unify the two APIs and eliminate some bugs along the way?


For reference, some key issues related to this:

@vscodebot vscodebot bot added editor editor-autoindent Editor auto indentation issues labels Sep 19, 2017
@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Nov 16, 2017
@alexdima alexdima removed the editor label Nov 23, 2017
@rebornix rebornix added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug labels Sep 19, 2018
@rebornix rebornix added this to the Backlog milestone Nov 3, 2020
@aiday-mar aiday-mar assigned aiday-mar and unassigned rebornix Mar 8, 2024
@aiday-mar aiday-mar added the typescript Typescript support issues label Mar 15, 2024
@aiday-mar aiday-mar removed the typescript Typescript support issues label Mar 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

4 participants