casid / jte-intellij

IntelliJ plugin for jte template files.
https://github.com/casid/jte
Apache License 2.0
23 stars 5 forks source link

Can't use tabs for indentation #21

Closed satsen closed 2 years ago

satsen commented 2 years ago

Even though I have configured indentation to be tabs for JavaTemplateEngine, it ignores this and writes 4 spaces when I press tab.

Toggling indents detection doesn't change anything.

IntelliJ version: 2022.1.3 Plugin version: 2.0.7

casid commented 2 years ago

Welcome, @satsen and thanks for reporting.

Did you change the settings here? This is working for me (IntelliJ 2021.3): image

Another pitfall might be that there are separate settings for jte files and kte files (in case you might use Kotlin).

Edit: I just upgraded to IntelliJ 2022.1.4 and tabs are still working for me.

satsen commented 2 years ago

Thanks, that works, but from the bottom bar under the editor changing it has no effect. It seems to configure another file type called "JavaTemplateEngine" while in the settings there is "jte".

satsen commented 2 years ago

@casid

casid commented 2 years ago

Hey @satsen, sorry for the late reply.

It took some reverse engineering to find out what the problem was. JavaTemplateEngine is the internal ID of the jte language. The display name of the code config option pane is jte, though. Apparently, that is not just the display name, but also the way IntelliJ finds out what code config option pane should be opened in com.intellij.psi.codeStyle.statusbar.CodeStyleStatusBarWidgetFactory#createDefaultIndentConfigureAction:

@NotNull
public static DumbAwareAction createDefaultIndentConfigureAction(@NotNull PsiFile psiFile) {
  String langName = getLangName(psiFile);
  return DumbAwareAction.create(
    ApplicationBundle.message("code.style.widget.configure.indents", langName),
    event -> {
      Configurable configurable = findCodeStyleConfigurableId(psiFile.getProject(), langName);
      if (configurable instanceof CodeStyleConfigurableWrapper) {
        ShowSettingsUtil.getInstance().editConfigurable(
          event.getProject(), configurable,
          () -> {
            CodeStyleConfigurableWrapper configurableWrapper = (CodeStyleConfigurableWrapper)configurable;
            configurableWrapper.setSchemesPanelVisible(false);
            configurableWrapper.selectTab(ApplicationBundle.message("title.tabs.and.indents"));
          });
      }
    }
  );
}

I've adjusted both display names to match each other, now the correct options are opened :-)

I just published version 2.0.8, it should be available for download after passing JetBrains review (usually takes about two business days).

satsen commented 2 years ago

@casid Thank you for fixing it and sharing detailed information about the cause! I just received the update, configuring from the bottom bar works as expected now.