-
Notifications
You must be signed in to change notification settings - Fork 352
Better ternary operator support #329
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
Comments
This is something I regularly run in to as well, just thought I'd voice my support for this issue. |
This is something that I run into as well. I have been running locally with this patch: jslatts/vim-javascript@b4b3936 It gets close, but doesn't totally handle some of my use cases with JSX. I also don't know if it has any adverse side effects since I am not familiar with vim-script. Happy to make it a PR if the maintainers think it is ok. |
The first example case you have provided should be fixed in Part of the challenge with this is that one size may not be able to fit all, to do it right there might have to be various modes that the indent file is put into, like comma first mode or whatever. Unfortunately, none of the maintainers know much about the indent side of things, it was an inherited piece of work from previous maintainers that are no longer around, and thus is not updated often. |
also a possible fix for the last example in pangloss#329 and pangloss#315
also a possible fix for the last example in pangloss#329 and pangloss#315
also a possible fix for the last example in pangloss#329 and pangloss#315
I'm for merging @jslatts solution as long as there aren't bad side effects |
FWIW, I have been using my patch since February without any side effects (that I have noticed). It doesn't help most of the time because I tend to use the ternary statements with JSX elements which still format poorly. |
Maybe we could use the same logic with every type of operator first? |
@jslatts can you make a PR with this change? I would recommend rebasing |
also a possible fix for the last example in pangloss#329 and pangloss#315
I think we can mark this issue resolved. All the issues described seem to be rectified in the There is a small caveat however, in the middle example: const foo = condition
? trueValue
: falseValue;
nextLineOfCode(); a manual However, the issue pointed out here: const foo = condition
? trueValue
: falseValue;
nextLineOfCode(); Where the |
I use ternary expressions a lot, as part of a more functional "assign-once" style. But I always have to manually adjust my indentation and make sure to never accidentally auto-indent the parts of my code that use them. Here's the indentation I would like to use:
However, the current implementation indents this code like so:
The text was updated successfully, but these errors were encountered: