diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java index 6badd0286cd6..e90cf4b20282 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateLookupElement.java @@ -66,15 +66,16 @@ abstract public class LiveTemplateLookupElement extends LookupElement { if (shortcut == TemplateSettings.DEFAULT_CHAR) { shortcut = TemplateSettings.getInstance().getDefaultShortcutChar(); } - if (shortcut != TemplateSettings.CUSTOM_CHAR) { - presentation.setTypeText(" [" + KeyEvent.getKeyText(shortcut) + "] "); - } else { + if (shortcut == TemplateSettings.CUSTOM_CHAR) { String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_CUSTOM)); if (StringUtil.isNotEmpty(shortcutText)) { presentation.setTypeText(" [" + shortcutText + "] "); } } + else if (shortcut != TemplateSettings.NONE_CHAR) { + presentation.setTypeText(" [" + KeyEvent.getKeyText(shortcut) + "] "); + } } if (StringUtil.isNotEmpty(myDescription)) { presentation.setTailText(" (" + myDescription + ")", true); diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java index a3f6761d0665..66e80430bd9e 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/LiveTemplateSettingsEditor.java @@ -80,6 +80,7 @@ public class LiveTemplateSettingsEditor extends JPanel { private static final String SPACE = CodeInsightBundle.message("template.shortcut.space"); private static final String TAB = CodeInsightBundle.message("template.shortcut.tab"); private static final String ENTER = CodeInsightBundle.message("template.shortcut.enter"); + private static final String NONE = CodeInsightBundle.message("template.shortcut.none"); private final Map myOptions; private final TemplateContext myContext; private JBPopup myContextPopup; @@ -241,7 +242,7 @@ public class LiveTemplateSettingsEditor extends JPanel { gbConstraints.gridx = 1; gbConstraints.insets = JBUI.insetsLeft(4); - myExpandByCombo = new ComboBox<>(new String[]{myDefaultShortcutItem, SPACE, TAB, ENTER}); + myExpandByCombo = new ComboBox<>(new String[]{myDefaultShortcutItem, SPACE, TAB, ENTER, NONE}); myExpandByCombo.addItemListener(new ItemListener() { @Override public void itemStateChanged(@NotNull ItemEvent e) { @@ -255,9 +256,12 @@ public class LiveTemplateSettingsEditor extends JPanel { else if(ENTER.equals(selectedItem)) { myTemplate.setShortcutChar(TemplateSettings.ENTER_CHAR); } - else { + else if (SPACE.equals(selectedItem)) { myTemplate.setShortcutChar(TemplateSettings.SPACE_CHAR); } + else { + myTemplate.setShortcutChar(TemplateSettings.NONE_CHAR); + } } }); expandWithLabel.setLabelFor(myExpandByCombo); @@ -503,9 +507,12 @@ public class LiveTemplateSettingsEditor extends JPanel { else if(myTemplate.getShortcutChar() == TemplateSettings.ENTER_CHAR) { myExpandByCombo.setSelectedItem(ENTER); } - else { + else if (myTemplate.getShortcutChar() == TemplateSettings.SPACE_CHAR) { myExpandByCombo.setSelectedItem(SPACE); } + else { + myExpandByCombo.setSelectedItem(TemplateSettings.NONE_CHAR); + } CommandProcessor.getInstance().executeCommand( null, () -> ApplicationManager.getApplication().runWriteAction(() -> { diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateSettings.java b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateSettings.java index 9538f0bcc731..440f7b7045d7 100644 --- a/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateSettings.java +++ b/platform/lang-impl/src/com/intellij/codeInsight/template/impl/TemplateSettings.java @@ -69,11 +69,13 @@ public class TemplateSettings implements PersistentStateComponent