Skip to content
This repository has been archived by the owner on Dec 19, 2024. It is now read-only.

Support proper code folding with Flow syntax #389

Open
SillyFreak opened this issue May 24, 2020 · 1 comment
Open

Support proper code folding with Flow syntax #389

SillyFreak opened this issue May 24, 2020 · 1 comment

Comments

@SillyFreak
Copy link

VS Code does not understand Flow type syntax and therefore gets confused by some non-js constructs when it comes to properly fold code blocks. Take this example code:

// @flow

type Ex1 = {
  // this is visible but shouldn't be

  foo: number,

  // this is visible but shouldn't be
};

function ex2() {
  // this is folded away

  type foo = {| x: number |};

  // this is visible but shouldn't be
}

function ex3() {
  // this is folded away

  function foo(x: { ... }) {}

  // this is visible but shouldn't be
}

function ex4() {
  // this is folded away

  const foo = (x: { ... }) => null;

  // this is visible but shouldn't be
}

function ex5() {
  // this is folded away

  function inner() {
    const foo = (x: { ... }) => null;
  }

  // this is visible but shouldn't be
}

image

When using the Fold All action, some of the comments will not be hidden because

  • types are not blocks to VS Code (Ex1)
  • exact types interrupt the current block (ex2)
  • explicit inexact types interrupt the current block (ex3, ex4)

With nested blocks (ex5), the interruption seems to end exactly the enclosing block, derailing the ancestor blocks by one closing brace each: the inner function ends one line too early at line 39, making its closing brace at line 40 end the ex5 function.

As even in Flow all braces match up, just in non-JS ways, I'm not sure if that is something that would have to be fixed in VS Code or here; I decided to report here because it is definitely impacting the Flow development experience.

@dandean
Copy link

dandean commented Oct 23, 2023

It's amazing to me that this hasn't been fixed yet.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants