question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Folded / Collpased code partially scrambled

See original GitHub issue

When reporting an issue, please include the following information in your post:

  • Explain the Issue and Expected Behavior
  • Prettier version
  • JsPrettier Plug-in Version
  • Platform Details
  • Generated Prettier command line arguments
  • Is the same behavior observed when run against Prettier directly?
  • The contents of your User/JsPrettier.sublime-settings file
  • The contents of your <project_name>.sublime-project file (if applicable)
  • Steps to reproduce the behavior

Explain the Issue and Expected Behavior

When invoiking JsPrettier (via direct command or on-save) while having folded code (Edit > Code Folding > Fold All) above or below the section I’m working on, the folded code is scrambled.

By scrambled I mean the code is not altered but the fold representation is not consistent anymore.

I would expect for the fold representation to remain unaltered.

Prettier version

1.16.1

JsPrettier Plug-in Version

1.27.0

Platform Details

macOS 10.14.5 SublimeText 3.2.1 (Build 3207)

Generated Prettier command line arguments


JsPrettier DEBUG - Prettier CLI Command

/Users/hunita/.nvm/versions/node/v8.11.4/bin/node /usr/local/bin/prettier --stdin --config /Users/user/test/.prettierrc --config-precedence cli-override --parser babel --use-tabs false --stdin-filepath /Users/user/test/test.js --loglevel debug --cursor-offset 249

Prettier reported the following output:

[debug] normalized argv: {"_":[],"color":true,"editorconfig":true,"stdin":true,"use-tabs":false,"config":"/Users/user/test/.prettierrc","config-precedence":"cli-override","parser":"babel","stdin-filepath":"/Users/user/test/test.js","loglevel":"debug","cursor-offset":249,"plugin-search-dir":[],"plugin":[],"ignore-path":".prettierignore","debug-repeat":0}
[debug] load config file from '/Users/user/test/.prettierrc'
[debug] loaded options `{"printWidth":80,"tabWidth":2,"useTabs":false,"semi":true,"singleQuote":false,"trailingComma":"none","arrowParens":"always"}`
[debug] applied config-precedence (cli-override): {"filepath":"/Users/user/test/test.js","arrowParens":"always","cursorOffset":249,"parser":"babel","printWidth":80,"semi":true,"singleQuote":false,"tabWidth":2,"trailingComma":"none","useTabs":false}

Is the same behavior observed when run against Prettier directly?

This is only related to code folding in SublimeText itself.

The contents of your User/JsPrettier.sublime-settings file

The entire contents of your User overridden JsPrettier Settings, excluding the comments.

{
  "node_path": "/Users/user/.nvm/versions/node/v8.11.4/bin/node",
  "prettier_cli_path": "/usr/local/bin/prettier",
  "prettier_options": {
    "singleQuote": true,
    "semi": false,
    "useTabs": false,
    "tabWidth": 2,
    "printWidth": 80
  },
  "auto_format_on_save": true,
  "debug": true,
  "auto_format_on_save_requires_prettier_config": true
}

The contents of your <project_name>.sublime-project file (if applicable)

N/A

Steps to reproduce the behavior

export function by2(param) {
  if (typeof param !== "number") {
    return param;
  }

  const result = param * 2;
  return result;
}

export function somethingElse(param) {
    if (!param) {
      throw new Error("Missing param1");
  }
}

When prettifying the code above, with the first function by2 folded in, you should see the first fold messed up.

I’m attaching screen shots to show what I mean:

  1. before image

  2. after image

In particualr I’m referring to the characters sult that appeard in the fold and the now swalloed am) {. This gets worse with more LOC in the same file.

Nonetheless very greatful for this plugin, thank you!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jonlabellecommented, Jun 29, 2019

No luck. Apparently (err assumingely), there were some internal changes which now cause the mentioned method to throw when attempting to refold the start/end regions.

0reactions
lock[bot]commented, Aug 13, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Code folding not working properly in certain circumstances
All code blocks should be folded after issuing a Fold All command. Interestingly, copying the contents of the file into a new editor...
Read more >
The Problem With Code Folding - Coding Horror
If the code needs the crutch of folding to look organized, it's bad code. Folding can hide deficiencies in your editor.
Read more >
Code partially unfolding when typing - TI E2E
I have code folding turned on. When I collapse a function or for loop, the code collapses as expected. After collapsing some functions, ......
Read more >
Fold code elements | JetBrains Rider Documentation
You can collapse (fold) code fragments reducing them to a single visible line. In this way, you can hide the details that, at...
Read more >
How do you feel about code folding? [closed] - Stack Overflow
When I open file I always start with Ctrl+M+O. This folds to method level. When you have regions you see nothing but region...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found