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

Format code does not work for javascript code #12359

Closed
galpeti opened this issue Sep 21, 2016 · 11 comments
Closed

Format code does not work for javascript code #12359

galpeti opened this issue Sep 21, 2016 · 11 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster languages-basic Basic language support issues verified Verification succeeded

Comments

@galpeti
Copy link

galpeti commented Sep 21, 2016

  • VSCode Version: 1.5.2
  • OS Version: wWn 10

Steps to Reproduce:

  1. Load unformatted Javascript file
  2. Select code and try to format it ( right click menu ) - nothing happens

It was working fine in previous versions.

@chrmarti
Copy link
Contributor

This works for me, could you paste the content of a file where the problem reproduces?

@chrmarti chrmarti self-assigned this Sep 21, 2016
@chrmarti chrmarti added the info-needed Issue requires more information from poster label Sep 21, 2016
@galpeti
Copy link
Author

galpeti commented Sep 26, 2016

Sorry for my late response.
Here is a code snippet. If I copy/paste it into a new file, it works.
Can it be that it is due to a setting ?

here is the contents of my settings.json :
{
"files.associations": {
"*.xmi": "xml"
},
// Controls the font size in pixels.
"editor.fontSize": 14,

"editor.wrappingColumn": 200

}

Code snippet:

} else if (xmiElem.stType === 'dataElements') {
console.log('Adding: ' + xmiElem.stType + ' Named: ' + xmiElem.name)
arGen.addSimpleNode(outNode, 'DATA-ELEMENTS')
childAdded = 'simple' // no aggregation element

  } else if (xmiElem.stType === 'applArrayDataType') {
console.log('Adding: ' + xmiElem.stType + ' Named: ' + xmiElem.name)
dataDef.addApplArrayDataType(xmiElem, outNode)

} else if (xmiElem.stType === 'implDataDefProp' ||
xmiElem.stType === 'implElemDataDefProp' ||
xmiElem.stType === 'paramDataDefProp' ||

@chrmarti
Copy link
Contributor

Your settings don't affect the formatter.

  • Are you selecting only the above lines?
  • Does it work if you format the complete file?
  • Could append a complete file that shows the issue?

@galpeti
Copy link
Author

galpeti commented Sep 29, 2016

Yep I was selecting only those lines. It did not work for the entire file.. I have tried that
Not allowed to append the entire file...

But I had to move the project into another folder, and now formatting works...
Do not know why.. strange.

@chrmarti chrmarti added bug Issue identified by VS Code Team member as probable bug languages-basic Basic language support issues and removed info-needed Issue requires more information from poster labels Sep 29, 2016
@chrmarti chrmarti assigned aeschli and unassigned chrmarti Sep 29, 2016
@ArnonEilat
Copy link

I'm having the same issue.

Running on ubuntu 14.04

Help menu -> About - showing this details:
Version 1.5.3
Commit 5be4091
Date 2016-09-22T08:40:08.699Z
Shell 0.37.6
Renderer 49.0.2623.75
Node 5.10.0

The contents of my settings.json :

// Place your settings in this file to overwrite the default settings
{
    // Controls the font size.
    "editor.fontSize": 16,
    // Zoom the font of the editor when using mouse wheel and holding Ctrl
    "editor.mouseWheelZoom": true,
    "javascript.validate.enable": false,
    // Adjust the zoom level of the window. The original size is 0 and each increment above (e.g. 1) or below (e.g. -1) represents zooming 20% larger or smaller. You can also enter decimals to adjust the zoom level with a finer granularity.
    "window.zoomLevel": 1,
    // When enabled, will trim trailing whitespace when you save a file.
    "files.trimTrailingWhitespace": true,
    // Whether existing line breaks before elements should be preserved. Only works before elements, not inside tags or for text.
    "html.format.preserveNewLines": false,
    // Controls if the editor will scroll beyond the last line
    "editor.scrollBeyondLastLine": false,
    // Controls whether the editor should render indent guides
    "editor.renderIndentGuides": false
}

@geogeim
Copy link

geogeim commented Oct 4, 2016

same issue here: shift-alt-f or using command bar to format code for js files has no effect. formatter works with json files.

after a healthy amount of swearing i found that if i delete node_modules from the current directory the code formatting for js works again so probably vscode tries to load something from there.

here's the package.json:

{
  "name": "delivery",
  "version": "0.0.0",
  "description": "delivery",
  "main": "server.js",
  "author": {
    "name": "Marian",
    "email": ""
  },
  "dependencies": {
    "body-parser": "^1.15.2",
    "express": "^4.14.0",
    "underscore": "^1.8.3",
    "webpack": "^1.13.2"
  }
}

VSCode:

Version 1.5.3
Commit 5be4091
Date 2016-09-22T08:50:42.185Z
Shell 0.37.6
Renderer 49.0.2623.75
Node 5.10.0

Node.js: v6.7.0
Windows 10 Pro: 10.0.14393

No user settings or workspace settings files present

@chrmarti
Copy link
Contributor

chrmarti commented Oct 4, 2016

@geogeim And does the problem come back when you install the node_modules again? Could you try the insiders build and confirm the problem is still present there: https://code.visualstudio.com/insiders

If it's still there, could you provide your workspace? I currently can't reproduce. Thanks.

@geogeim
Copy link

geogeim commented Oct 5, 2016

try to reproduce this file structure:

folder/node_modules
folder/package.json
folder/file_to_format.js
jsconfig.json
  • if i delete node_modules then formatting works, if i add it back it stops working
  • i tested with the insiders build and i can't reproduce it

if you still can't reproduce it i apologize, i will upload a test project

@aeschli aeschli assigned dbaeumer and unassigned aeschli Oct 10, 2016
@dbaeumer dbaeumer assigned waderyan and unassigned dbaeumer Oct 11, 2016
@waderyan
Copy link

@geogeim @ArnonEilat @galpeti thank you for making us aware of this issue. I am having a hard time reproducing what you are seeing I have tried the code samples above but to no avail. There is some discussion on that this is due to a node_modules folder. I have also tried to recreate the bug using my JavaScript projects. It has not worked.

Can one or all of you share a minimal repo where this behavior is seen? Also, please move to v1.6 of VS Code.

@waderyan waderyan added the info-needed Issue requires more information from poster label Oct 14, 2016
@geogeim
Copy link

geogeim commented Oct 19, 2016

Retested with 1.5.3 still reproducible but not reproducible on
Version 1.6.0
Commit e52fb0b
Date 2016-10-10T18:37:40.189Z
Shell 1.3.7
Renderer 52.0.2743.82
Node 6.5.0

@waderyan
Copy link

Closing this as fixed in 1.6.0.

@octref octref added the verified Verification succeeded label Oct 27, 2016
@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster languages-basic Basic language support issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests

8 participants