Skip to content

'reindent all lines' removes leading space in comment #19142

Closed

Description

Testing #19091:
In a typescript file:

/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

'use strict';
class A {
}
  • use the 'Reindent all lines' command
  • check out the file comment. The space before '*' has been removed
/*---------------------------------------------------------------------------------------------
*  Copyright (c) Microsoft Corporation. All rights reserved.
*  Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

Activity

  1. rebornix commented on Jan 24, 2017

    @rebornix
    Contributor

    Block comment's indentation is currently handled by onEnterRules and not filtered out in Indentation Rules. There are actually two ways to mitigate this issue

    1. Honor onEnterRules in Reindent lines, which is a breaking change
    2. Enhance Indentation Rules for TypeScript. The indentation rule set I mentioned in 'reindent all lines' and formatter have different formatting strategies #19140 (comment) still doesn't fix this problem. A proper fix is likely filtering block comments in unIndentPattern if possible.
  2. added
    under-discussion
    on Apr 19, 2017
  3. added
    editor-autoindent
    on Jun 7, 2017
  4. hexpunk commented on Oct 11, 2018

    @hexpunk

    FWIW, this affects pretty much all languages with doc comments, not just typescript. I experienced this bug today in a PHP file.

  5. jpw commented on Jun 12, 2019

    @jpw

    Yes, I'm not sure the typescript label is relevant here.

    My use case is I'm about to sort out lots of formatting issues in a rough-looking ES6 codebase that does at least have JSDoc comments, and I think I cant use "Reindent lines" to do so without messing up the comments (thereby annoying linters, and/or changing the code style). I will have to subsequently do a regexp find & replace on all the block comments (also regexp may vary per file), or a lot of copy & pasting around :(

    Also see this stackoverflow issue (I am not the author of that).

  6. added
    *out-of-scope
    on Oct 11, 2019
  7. vscodebot commented on Oct 11, 2019

    @vscodebot

    This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that are not going to be addressed in the foreseeable future: We look at the number of votes the issue has received and the number of duplicate issues filed. More details here. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.

    If you wonder what we are up to, please see our roadmap and issue reporting guidelines.

    Thanks for your understanding and happy coding!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

*out-of-scopeeditor-autoindenttypescriptunder-discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions