Skip to content

Add support for disabling formatter for a code block #33772

Closed

Description

  • VSCode Version: Code 1.15.0 (8b95971, 2017-08-09T20:16:18.034Z)
  • OS Version: Windows_NT x64 6.1.7601

This is a feature request. I wanted a way to disable formatter for a block of code based on some sort of annotations. This will be handy for cases that are not yet supported by VSCode formatter. For example, support for dynamic imports were added in v1.14. Before that import() statements were not getting formatted properly.

Activity

  1. jrieken commented on Sep 4, 2017

    @jrieken
    Contributor

    code based on some sort of annotations

    Like what? Can provide a sample? Is this for one specific language? And is this just a workaround for shortcomings of the formatter?

  2. varunkumar commented on Sep 4, 2017

    @varunkumar
    Author

    Here is a sample format that could be used. This is not just a workaround for shortcomings. This can be useful for cases where developers want to format a section of code differently.

    const generateData = () => {
      const items = [];
      for (let i = 0; i < 100; i++) {
         /* formatter: off */
        const item = {
          id        : i,
          name      : `item${i}`,
          category  : 'some category'
        }
        /* formatter: on */
        items.push(item);
      }
    }
  3. jrieken commented on Sep 4, 2017

    @jrieken
    Contributor

    This seems JS/TS specific

  4. added
    upstreamIssue identified as 'upstream' component related (exists outside of VS Code)
    on Sep 5, 2017
  5. mjbvz commented on Sep 5, 2017

    @mjbvz
    Contributor

    I've opened microsoft/TypeScript#18261 to track for our built-in JavaScript and TypeScript formatter

    Closing as upstream

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

Metadata

Metadata

Labels

formattingSource formatter issuesjavascriptJavaScript support issuestypescriptTypescript support issuesupstreamIssue identified as 'upstream' component related (exists outside of VS Code)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions