Comments (5)
Done with 1.4.0.
Just update your extension! The setting is formattingToggle.activateFor
.
Thank you! :)
from vscode-formatting-toggle.
@Tom-Bonnike Thanks for the prompt response! The reason I bring it up is because I've never found formatOnPaste
to be desirable. In most cases it does more harm than good. Check out the demo below:
Notice how as I start to add a newProp
to my React component, I paste the name of the method that I want to assign for the newProp
's value. Immediately on paste, it tries to format (in my case Prettier), which leads to a lot of visual confusion as the cursor has now moved and all the formatting of the file has gone haywire simply because I pasted in a method. This is one of many situations I've run into. Now imagine if formatOnPaste
is off, I would paste, and finish making my changes, and save file. At that point my formatter would kick in and make whatever changes necessary, and I see a ✅ at the bottom right. I know I've done it right and move on.
Another reason is that I rely on my formatter to correct my syntax. Say if I've missed a (
somewhere, my formatter would immediately show a X
at the bottom corner of VS Code. So if my code doesn't format itself, I know I've missed something somewhere. It's a nice sanity check while saving changes onto a file, and I'd rather have that check happen on Save, and not on Paste. Because a paste doesn't mean that I'm done making my changes and now want it to be formatted, but a Save does.
I think your last suggestion is great. What if we ship some default options for what most users would use, and then allow the user to override? That way current users can keep using the Plugin as normal, and picky users like me can add an extra key to their settings JSON?
Like you said, if I was able to add to my settings.json
file a formattingToggle.activate = ["formatOnSave"]
, my Formatting toggle would only formatOnSave, and I can toggle away and live happily ever after. 😄
from vscode-formatting-toggle.
OK, I was just curious, but it makes a lot of sense to allow users to choose which settings are set back on anyway! I’ll try to find some time to implement it ASAP 😌
from vscode-formatting-toggle.
vscode-formatting-toggle/src/initCommand/index.ts
Lines 39 to 51 in 62a25bb
Haha “probably safe”.
In https://github.com/Tom-Bonnike/vscode-formatting-toggle/blob/master/src/initCommand.ts, I’m saving the initial editor.…
configuration. This is only done once, when VSCode starts. This is useful so that I can set the value back to what it was for formatOnType
, since I’m assuming very few people actually turn this setting on and so they wouldn’t want it put back to true
.
I didn’t do it for formatOnPaste
and formatOnSave
because:
- If I put those settings back to their initial value, they could both be set back to
false
… But as a user I would expect the extension to always activate them, even if they were deactivated when I first launched VS Code. - I simply assumed that’s what most people use and that it wouldn’t cause any problem.
Could you please explain why you dislike formatOnPaste
? 🤔Do you have any suggestion on how I could handle that? I can’t really guess if the user wants formatOnPaste
or not… :/
Maybe I could add some settings that I would use? Wouldn’t that be overkill? 😄
Something like: formattingToggle.activate = ["formatOnPaste", "formatOnSave"]
?
And I could simply do what I’m doing right now if this setting isn’t found.
I might be missing a simpler solution? :)
from vscode-formatting-toggle.
Wow, that was quick! Thank you so much - this is amazing 😍
from vscode-formatting-toggle.
Related Issues (20)
- Please add "deactivateFor" HOT 4
- Infer `formattingToggle.affects` from the initial user configuration HOT 2
- Does not work with ESLint extension HOT 2
- Please support "editor.codeActionsOnSave" HOT 10
- Support toggling `files` formatting options HOT 3
- Does not work in Remote - Containers or GitHub Codespaces HOT 8
- [Feature Request] Remember the format on settings instead of reset it? HOT 1
- Handle workspace settings / mention it in the documentation HOT 7
- No toggle in my status bar HOT 6
- bisect results HOT 3
- Please add scope parameter to disable formatting for current workspace HOT 15
- Toggle is not working. Error visible in the VSC console HOT 3
- Formatting Toggle does not work? HOT 3
- Implement disabling formatting on save via keybinding override HOT 6
- Add Setting for Status Bar Text HOT 1
- [Feature Request] Indentation of Preprocess Instructions HOT 1
- Incorrect Formatting Issue HOT 1
- feature request: github dev support HOT 1
- Issues with Version: 1.85.0 and/or workspace settings HOT 1
- The status bar element disappears from the status bar when switching to a code editor HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vscode-formatting-toggle.