I can't figure how to Android Studio handle the styling of the foreach
live template by putting it on two line like this:
for ( :
) {
}
Editor -> Live templates -> Android -> foreach
we can unselect Reformat according to style and it stays on one line but it looks like a temporary fix.I want to find where (according to style
) is, to be able to modify it.
Thanks
I think it's a bug related with 'Reformat according to style' option.
As you know, to prevent wrong wrapping, turn off 'Reformat according to style" option for 'foreach' Live Template.
Editor > Live Templates > Android > foreach > Reformat according to style
Here is my explanation:
There are styles for 'for()' statement in
Code Style > Java > Wrapping and Braces > 'for()' statement
It makes wrapping when using 'Live Templates' with 'Reformat according to style' option. It's not about Code Style rule because it doesn't wrap when already typed foreach loop.
After some testing with template text and applying Code Style, I figured out the problem is WHEN Code Style applied. 'Reformat according to style' option is applied BEFORE template text interpreted, so Code Style for 'for()' applied to below text and it wraps.
for ($i$ : $data$) {
$cursor$
}
Type that template text in editor and 'Reformat Code', it wraps like this.
for ($i$:
$data$) {
$cursor$
}
That's why live template works like that.
It's just a bug and you can use the temporary fix until bug fixed.
You can modify it at the very same path you mentioned in the question.
Editor -> Live templates -> Android -> foreach
select foreach
and at the bottom you see a textarea with the formatting/style. Modify it as you wish and click Apply
The style you are referring to is i think the code style.
Can be found at
Editor -> Code Styles
Check this screenshot"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With