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

switch tab: "case" align with "switch" #179

Closed
damienleroux opened this issue Oct 30, 2015 · 10 comments
Closed

switch tab: "case" align with "switch" #179

damienleroux opened this issue Oct 30, 2015 · 10 comments

Comments

@damienleroux
Copy link

Hi,

I note that switch statement use wrong tabulation:

function execute() {
  switch (test) {
  case a:
    break;
  }
}

It should be:

function execute() {
  switch (test) {
    case a:
      break;
  }
}

Let me know if I miss configuration possibilities or if you can enhance jsfmt with this?

Thank you!

@brettlangdon
Copy link
Contributor

@damienleroux which version of jsfmt are you using?

I just tested with v0.5.1 and seems to work as expected:

Input:

function execute(test) {
  switch (test) {
  case a:
    break;
  }
}

switch (test) {
case a:
  break;
}

Formatted:

function execute(test) {
  switch (test) {
    case a:
      break;
  }
}

switch (test) {
  case a:
    break;
}

@damienleroux
Copy link
Author

I tested it in another Sublime Text: same problem...

@brettlangdon
Copy link
Contributor

Ok, it might be an issue with the Sublime plugin since this does not appear to be an issue with the latest version of jsfmt. Can you let me know what version of the sublime-jsfmt plugin you are using, as well as your version of node.js and any other information (e.g. are you using nvm or anything else?).

Also, is everything else getting formatted just fine? It is just switch statements which get reformatted wrong?

@damienleroux
Copy link
Author

I reproduce the case on a sublime text 3 64 bit ( portable version) on Window 7 64 installed from scratch.
I installed browser package on it.
I installed jsfmt through it: the file package.json in D:\Sublime Text test\Data\Packages\jsfmt is:

{
  "name": "sublime-jsfmt",
  "dependencies": {
    "esformatter-braces": "^1.2.1",
    "esformatter-dot-notation": "^1.3.1",
    "esformatter-quotes": "^1.0.3",
    "esformatter-semicolons": "^1.1.1",
    "extend": "^3.0.0",
    "get-stdin": "^4.0.1",
    "jsfmt": "^0.5.0"
  },
  "engines": {
    "node": ">=0.10.0"
  },
  "private": true
}

There is no mention of a particular version of sublime-jsfmt.
I have installed no other package.
I am using node v4.2.1.

I have a similar probleme formatting with this code:

function test() {
    var mytest;
}

module.exports = function test() {
    var mytest;
}

This code is formatted like this:

function test() {
    var mytest;
}

module.exports = function test() {
var mytest;
}

It seems the statement "module.exports = " breaks tabulation inside the function.

@brettlangdon
Copy link
Contributor

Hmm, this might be an issue with sublime-jsfmt, again, I don't have any issues with formatting your example code on jsfmt@0.5.1 and node@4.2.1.

I have opened mihai-vlc/sublime-jsfmt#37 as I believe this might be an issue with sublime-jsfmt, and even if it is not someone over there might be able to help us debug and resolve this issue.

@brettlangdon
Copy link
Contributor

Also, I am sorry that you are having difficulties, hopefully we can help get them resolved.

@damienleroux
Copy link
Author

Thank you very much for helping :). It gives me hope

@brettlangdon
Copy link
Contributor

@damienleroux have you had any luck here?

@damienleroux
Copy link
Author

Yes,

As explained by from sublime jsfmt support, adding "TopLevelFunctionBlock" resolved my problem.

Thank you for your help!

@brettlangdon
Copy link
Contributor

Great, glad you were able to resolve the problem!

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

No branches or pull requests

2 participants