Getting indent settings from CodeStyleSettings does not work.
已回答
When using CodeStyleSettings settings = CodeStyleSettingsManager.getInstance(project).getMainProjectCodeStyle();
with my style settings changed from the default (Tab Size: 2, Indent: 2), I still get a response of 4 (the default size) when calling any of the following:
settings.getTabSize(JavaFileType)
settings.getIndentOptions().TAB_SIZE
settings.getIndentOptions().INDENT_SIZE
even though they should all give a response of 2 due to the setting changes.
Has anyone experienced this before, or am I just using this incorrectly?
请先登录再写评论。
Hi,
Please provide more information.
Where do you change the settings? Please paste screenshot.
What is the full context of the code? Please share the whole method or class.
Hi,
Settings are changed in the settings menu, have attached screenshot below. For the record, I have changed default, demo, and project settings all with the same results.
This is the method attempting to get the tab size, as mentioned I have tried many different methods to get the tab size.
And to get the project, I'm using the following line in my action:
this.project = e.getRequiredData(CommonDataKeys.PROJECT);
Let me know if you'd like any more context.
Thanks.
Please try one of
com.intellij.application.options.CodeStyle
's static methods, e.g.,getSettings()
orgetLanguageSettings()
.Great that worked. Thank you Kaorl