From d5be2396f1a28c093045d38d33fb17349e951ad7 Mon Sep 17 00:00:00 2001 From: Dmitry Jemerov Date: Wed, 19 Jun 2019 20:13:09 +0200 Subject: [PATCH] Don't show empty parentheses in action description when there's no shortcut assigned for Web Preview GitOrigin-RevId: 1be17fc7e71c500076f21282bdc1cea0c66932bb --- .../actions/BaseOpenInBrowserAction.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/xml/impl/src/com/intellij/ide/browsers/actions/BaseOpenInBrowserAction.kt b/xml/impl/src/com/intellij/ide/browsers/actions/BaseOpenInBrowserAction.kt index b3a365d5857b..f3dff77be28c 100644 --- a/xml/impl/src/com/intellij/ide/browsers/actions/BaseOpenInBrowserAction.kt +++ b/xml/impl/src/com/intellij/ide/browsers/actions/BaseOpenInBrowserAction.kt @@ -99,19 +99,21 @@ internal class BaseOpenInBrowserAction(private val browser: WebBrowser) : DumbAw var description = templatePresentation.text if (ActionPlaces.CONTEXT_TOOLBAR == e.place) { - val builder = StringBuilder(description) - builder.append(" (") - val shortcuts = KeymapManager.getInstance().activeKeymap.getShortcuts("WebOpenInAction") - val exists = shortcuts.isNotEmpty() - if (exists) { - builder.append(KeymapUtil.getShortcutText(shortcuts[0])) - } + val shortcutInfo = buildString { + val shortcuts = KeymapManager.getInstance().activeKeymap.getShortcuts("WebOpenInAction") + val exists = shortcuts.isNotEmpty() + if (exists) { + append(KeymapUtil.getShortcutText(shortcuts[0])) + } - if (HtmlUtil.isHtmlFile(result.file)) { - builder.append(if (exists) ", " else "").append("hold Shift to open URL of local file") + if (HtmlUtil.isHtmlFile(result.file)) { + append(if (exists) ", " else "") + append("hold Shift to open URL of local file") + } + } + if (shortcutInfo.isNotEmpty()) { + description = "$description ($shortcutInfo)" } - builder.append(')') - description = builder.toString() } e.presentation.text = description }