diff --git a/CHANGELOG.md b/CHANGELOG.md index ea7b66b3..5ed4fc30 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,9 +1,15 @@ # Changelog +## [v3.2.2] – 2023-06-28 + +- Elixir: fixed module function call regression in captures (`&Map.take(&1, @fields)`). +- Elixir: recognize special macro `defmacro (..) do end`. +- Commands: added `mix_test_hide_panel` command. + ## [v3.2.1] – 2023-06-24 -- Elixir: fixed quoted module name function calls such as `:"Elixir.Kernel".in(1, [1])` -- SQL: recognize `CREATE TYPE` +- Elixir: fixed quoted module name function calls such as `:"Elixir.Kernel".in(1, [1])`. +- SQL: recognize `CREATE TYPE`. ## [v3.2.0] – 2023-05-02 diff --git a/commands/Default.sublime-commands b/commands/Default.sublime-commands index 82e83954..0e355e41 100644 --- a/commands/Default.sublime-commands +++ b/commands/Default.sublime-commands @@ -15,6 +15,7 @@ { "caption": "Mix Test: Toggle --stale Flag", "command": "mix_test_toggle_stale_flag" }, { "caption": "Mix Test: Switch to Code or Test", "command": "mix_test_switch_to_code_or_test" }, { "caption": "Mix Test: Show Panel", "command": "mix_test_show_panel" }, + { "caption": "Mix Test: Hide Panel", "command": "mix_test_hide_panel" }, { "caption": "Mix Format: File", "command": "mix_format_file" }, { "caption": "Mix Format: Project / Folder", "command": "mix_format_project" }, { "caption": "Mix Format: Toggle Auto-Formatting", "command": "mix_format_toggle_auto_format" }, diff --git a/commands/mix_format.py b/commands/mix_format.py index 465252e9..2ae6a07d 100644 --- a/commands/mix_format.py +++ b/commands/mix_format.py @@ -76,10 +76,7 @@ def call_mix_format(window, **kwargs): cwd = next((reverse_find_root_folder(p) for p in paths if p), None) if not (cwd or file_path): - print_status_msg( - 'Error: could not find a mix.exs file and the _build/ directory! ' - + 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.' - ) + print_status_msg(COULDNT_FIND_MIX_EXS) return proc = subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) diff --git a/commands/mix_test.py b/commands/mix_test.py index 8283f90f..9efce451 100644 --- a/commands/mix_test.py +++ b/commands/mix_test.py @@ -35,10 +35,7 @@ def run(self, **_kwargs): sublime_NewFileFlags_NONE = 4 self.window.open_file(mix_settings_path, flags=sublime_NewFileFlags_NONE) else: - sublime.message_dialog( - 'Error: could not find a mix.exs file and the _build/ directory!\n' + - 'Make sure that you are in a mix project and that `mix do deps.get + compile` has been run.' - ) + sublime.message_dialog(COULDNT_FIND_MIX_EXS) class MixTestCommand(sublime_plugin.WindowCommand): def description(self): @@ -280,7 +277,17 @@ def run(self, **_kwargs): self.window.run_command('show_panel', {'panel': PANEL_NAME}) def is_enabled(self): - return PANEL_NAME in self.window.panels() + return PANEL_NAME != self.window.active_panel() and PANEL_NAME in self.window.panels() + +class MixTestHidePanelCommand(sublime_plugin.WindowCommand): + def description(self): + return 'Hides the output panel if visible.' + + def run(self, **_kwargs): + self.window.run_command('hide_panel', {'panel': PANEL_NAME}) + + def is_enabled(self): + return PANEL_NAME == self.window.active_panel() # Helper functions: @@ -431,10 +438,7 @@ def reverse_find_json_path(window, json_file_path): paths = [window.active_view().file_name()] + window.folders() root_dir = next((reverse_find_root_folder(p) for p in paths if p), None) - root_dir or print_status_msg( - 'Error: could not find a mix.exs file and the _build/ directory! ' - + 'Make sure that you are in a mix project and that `mix do deps.get + compile` was run.' - ) + root_dir or print_status_msg(COULDNT_FIND_MIX_EXS) return root_dir and path.join(root_dir, json_file_path) or None diff --git a/commands/utils.py b/commands/utils.py index 92ccf745..de07345a 100644 --- a/commands/utils.py +++ b/commands/utils.py @@ -10,6 +10,10 @@ PRINT_PREFIX = 'ElixirSyntax:' +COULDNT_FIND_MIX_EXS = \ + 'Error: could not find a mix.exs file and the _build/ directory!\n' + \ + 'Make sure that you are in a mix project and that `mix \'do\' deps.get, compile` has been run.' + def print_status_msg(msg): print(PRINT_PREFIX, msg) sublime.status_message(PRINT_PREFIX + ' ' + msg) @@ -65,4 +69,4 @@ def load_json_file(file_path): exists = Path(file_path).exists() exists and print_status_msg('Error: could not open file: %r\nException: %s' % (file_path, e)) - return {} \ No newline at end of file + return {} diff --git a/syntaxes/Elixir.sublime-syntax b/syntaxes/Elixir.sublime-syntax index 51cced51..4b89c5ed 100644 --- a/syntaxes/Elixir.sublime-syntax +++ b/syntaxes/Elixir.sublime-syntax @@ -196,6 +196,13 @@ contexts: scope: entity.name.function.elixir set: function_free_form_header_pop + - match: (\()\s*(\.\.)\s*(\)) + captures: + 1: punctuation.section.group.begin.elixr + 2: entity.name.function.elixir + 3: punctuation.section.group.end.elixr + set: function_free_form_header_pop + - include: atom_keyword - include: func_do_block_pop - include: block_or_keyword @@ -2339,9 +2346,6 @@ contexts: set: - include: dot_operator - include: capture_name_pop - - match: (?={{member}}{{no_id_key_suffix}}) - push: id_member_pop - - include: if_closing_token_pop - include: member_or_call_pop - include: capture_name_pop - include: special_form diff --git a/tests/syntax_test_declarations.ex b/tests/syntax_test_declarations.ex index d77c3349..86b501b0 100644 --- a/tests/syntax_test_declarations.ex +++ b/tests/syntax_test_declarations.ex @@ -403,6 +403,10 @@ def .. a do a end def ..(a) do a end # ^ punctuation.section.group.begin # ^^ keyword.operator.range +defmacro (..) do range(__CALLER__.context, 0, -1, 1) end +# ^ punctuation.section.group.end +# ^^ entity.name.function +# ^ punctuation.section.group.begin def ... a do a end # ^^^ entity.name.function def ...(a) do a end diff --git a/tests/syntax_test_misc.ex b/tests/syntax_test_misc.ex index f41a5bbc..a4a85bc2 100644 --- a/tests/syntax_test_misc.ex +++ b/tests/syntax_test_misc.ex @@ -887,6 +887,12 @@ end[] # ^^^ variable.other.capture # ^^^^^^^ variable.other.capture + &Module.func(&1) +# ^ punctuation.section.arguments.end +# ^ punctuation.section.arguments.begin +# ^^^^ variable.function +# ^ punctuation.accessor.dot + &Module |> func(&1) # ^^^^ variable.function # ^^ keyword.operator.pipe -punctuation.accessor.arity