diff --git a/plugin/rename.py b/plugin/rename.py index e697c267b..ca19fdd73 100644 --- a/plugin/rename.py +++ b/plugin/rename.py @@ -24,15 +24,16 @@ import sublime_plugin -BUTTON_HTML = """ +BUTTONS_TEMPLATE = """ - - {label} + + Apply + Discard """ -DISCARD_BUTTON_HTML = BUTTON_HTML.format( - label="Discard", - command=sublime.command_url('chain', { - 'commands': [ - ['hide_panel', {}], - ['lsp_hide_rename_buttons', {}] - ] - }), - color="#3f3f3f", - color_light="#636363" -) +DISCARD_COMMAND = sublime.command_url('chain', { + 'commands': [ + ['hide_panel', {}], + ['lsp_hide_rename_buttons', {}] + ] +}) def is_range_response(result: PrepareRenameResult) -> TypeGuard[Range]: @@ -247,7 +250,7 @@ def _render_rename_panel( return to_render = [] # type: List[str] reference_document = [] # type: List[str] - header_lines = "{} changes across {} files.\n\n \n".format(total_changes, file_count) + header_lines = "{} changes across {} files.\n\n".format(total_changes, file_count) to_render.append(header_lines) reference_document.append(header_lines) ROWCOL_PREFIX = " {:>4}:{:<4} {}" @@ -294,10 +297,9 @@ def _render_rename_panel( buttons = pm.rename_panel_buttons if not buttons: return - buttons_position = len(to_render[0]) - 2 - APPLY_BUTTON_HTML = BUTTON_HTML.format( - label="Apply", - command=sublime.command_url('chain', { + buttons_position = sublime.Region(len(to_render[0]) - 1) + BUTTONS_HTML = BUTTONS_TEMPLATE.format( + apply=sublime.command_url('chain', { 'commands': [ [ 'lsp_apply_workspace_changes', @@ -313,12 +315,10 @@ def _render_rename_panel( ] ] }), - color="var(--accent)", - color_light="var(--accent)" + discard=DISCARD_COMMAND ) buttons.update([ - sublime.Phantom(sublime.Region(buttons_position), APPLY_BUTTON_HTML, sublime.LAYOUT_INLINE), - sublime.Phantom(sublime.Region(buttons_position + 1), DISCARD_BUTTON_HTML, sublime.LAYOUT_INLINE) + sublime.Phantom(buttons_position, BUTTONS_HTML, sublime.LAYOUT_BLOCK) ])