-
Notifications
You must be signed in to change notification settings - Fork 4
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
$DefaultBreakLinesMethod = None #4
Comments
At 25:26 of your 2020 WTC video, you say the formatter tries to preserve line breaks added by the user. It doesn't seem to right now. Being able to set |
After that presentation, there have been several updates to CodeFormatter and one was to canonicalize the output by always first stripping out whitespace and newlines. (specifically 47a3386) This fixes a problem of "history dependence" on input and Airiness settings, i.e., you want to be able to interactively change Airiness and you want to always get the same output for each Airiness setting. If the newlines are preserved, then there is an undesirable "hysteresis" effect. Now, what you want of not changing newlines at all (not removing existing newlines and not adding new ones) and only modifying whitespace is a good idea and other people have also asked for this sort of thing. It would not be formatting per se, and I would call this something new like "Fix indentation" or "Fix whitespace" or "Redo whitespace" (suggestions please!) And could be provided as a different menu item in editors that we support like VSCode and Sublime. |
Unfortunately, there is no I believe specifying:
in your VSCode command will get you want (with appropriate values specified and making sure to properly escape the strings, and possibly removing spaces because I am paranoid about running commands with spaces in them). |
Nice! Set options on It'd be nice if there was an Airiness level that put the commas on the same line as the code.
to this at -0.85 (notice LineWidth is not respected)
|
EDIT: I had Wolfram.command edited in the wrong settings file. I copy-pasted into both (.vscode/settings, and user settings). It's working now ORIGINAL: Is there not a 1-to-1 mapping between
|
I'm having trouble reproducing example in your question about going from Can you show all the steps that you used starting with a fresh kernel? |
Your example above has I can also work to warn about unrecognized values for options. |
Here's a notebook if it helps: |
Yes, I see the same thing. I'm sorry, can you give an example of what you are seeing vs. what you are requesting? |
Maybe at Airness -> -0.75, the commas stay on the previous line like this:
Reason being, I can then use a plugin to help align the code further to make it more readable and more compact: Here's another example using multi-column alignment: I use "Smart Column Indenter," which doesn't work as well with the comma breaking the pattern between each line. What do you think? |
It's a good idea and there is already some cases where commas are kept on the same line if the structure is known. e.g.
but it's not a general solution and I have to make some changes to allow it to work in general. |
I would like CodeFormatter to help me with spacing and indentation but not line breaks. I'd like it to
So if I write:
I would like it to return
i.e. add spacing and indentation, but do not add or remove line breaks
Is there a way to do this? I tried $DefaultBreakLinesMethod=None, but it appears that symbol has to be set to a string. And I would like to apply these settings in VS Code so I can use "Format Document" or "Format Selection".
The text was updated successfully, but these errors were encountered: