Skip to content

Commit 8679261

Browse files
jbodahkassio
authored andcommitted
Fix bug with unused args when function signature spans multiple lines (#215)
Fixes #196
1 parent 27b0308 commit 8679261

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

spec/syntax/variable_spec.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def handle_call(:pop)
1919
EOF
2020
end
2121

22-
pending 'unused, multiple lines' do
22+
it 'unused, multiple lines' do
2323
expect(<<~EOF).to include_elixir_syntax('elixirUnusedVariable', '_from')
2424
def handle_call(:pop,
2525
_from,
@@ -29,7 +29,15 @@ def handle_call(:pop,
2929
EOF
3030
end
3131

32-
pending 'unused in pattern_match' do
32+
it 'unused, single char' do
33+
expect(<<~EOF).to include_elixir_syntax('elixirUnusedVariable', '_')
34+
def call(:pop, _, [h|stack]) do
35+
{ :reply, h, stack }
36+
end
37+
EOF
38+
end
39+
40+
it 'unused in pattern_match' do
3341
str = <<~EOF
3442
def sign_in(conn, %{
3543
"data" => %{

syntax/elixir.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ set cpo&vim
88
" syncing starts 2000 lines before top line so docstrings don't screw things up
99
syn sync minlines=2000
1010

11-
syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition
11+
syn cluster elixirNotTop contains=@elixirRegexSpecial,@elixirStringContained,@elixirDeclaration,elixirTodo,elixirArguments,elixirBlockDefinition,elixirUnusedVariable
1212
syn cluster elixirRegexSpecial contains=elixirRegexEscape,elixirRegexCharClass,elixirRegexQuantifier,elixirRegexEscapePunctuation
1313
syn cluster elixirStringContained contains=elixirInterpolation,elixirRegexEscape,elixirRegexCharClass
1414
syn cluster elixirDeclaration contains=elixirFunctionDeclaration,elixirModuleDeclaration,elixirProtocolDeclaration,elixirImplDeclaration,elixirRecordDeclaration,elixirMacroDeclaration,elixirDelegateDeclaration,elixirOverridableDeclaration,elixirExceptionDeclaration,elixirCallbackDeclaration,elixirStructDeclaration
@@ -37,7 +37,7 @@ syn keyword elixirInclude import require alias use
3737
syn keyword elixirSelf self
3838

3939
" This unfortunately also matches function names in function calls
40-
syn match elixirUnusedVariable '\(([^)]*\)\@<=\<_\w*\>'
40+
syn match elixirUnusedVariable contained '\<_\w*\>'
4141

4242
syn keyword elixirOperator and not or in
4343
syn match elixirOperator '!==\|!=\|!'

0 commit comments

Comments
 (0)