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

Allow folding switch_default #644

Merged
merged 1 commit into from Apr 10, 2019

Conversation

Projects
None yet
2 participants
@Ben3eeE
Copy link
Member

commented Apr 3, 2019

Requirements

  • Filling out the template is required. Any pull request that does not include enough information to be reviewed in a timely manner may be closed at the maintainers' discretion.
  • All new code requires tests to ensure against regressions

Description of the Change

case statements in javascript are parsed as:
switch_statement > switch_body >switch_case

Default case statements in javascript are parsed as:
switch_statement >switch_body > switch_default

This PR adds switch_default to the folding rules so default can be folded with the same rule as case.

Alternate Designs

N/A

Benefits

Consistent folding rules for switch statements

Possible Drawbacks

Someone likes unfoldable default and will open an issue that they can now fold it

Applicable Issues

N/A

Verification Process

const fun = () => {
  switch (variable) {
    case DO_STUFF:
      do_stuff();
      break;
    case DO_OTHER_STUFF:
      do_other_stuff();
      test();
      break;
    default:
      do_stuff();
      test();
      break;
  }
};
  • Can not fold the default before this change
  • Can fold the default after this change
  • Run editor:log-cursor-syntax-tree-scope in the default and the switch to verify that they are parsed differently

@nathansobo nathansobo self-assigned this Apr 10, 2019

@nathansobo

This comment has been minimized.

Copy link
Contributor

commented Apr 10, 2019

❤️ This will be nice.

@nathansobo nathansobo merged commit 6e90f7b into master Apr 10, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@Ben3eeE Ben3eeE deleted the b3-fold-default branch Apr 11, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.