diff options
-rw-r--r-- | autoload/ale/engine.vim | 5 | ||||
-rw-r--r-- | autoload/ale/highlight.vim | 2 | ||||
-rw-r--r-- | test/test_highlight_placement.vader | 13 | ||||
-rw-r--r-- | test/test_loclist_corrections.vader | 36 |
4 files changed, 55 insertions, 1 deletions
diff --git a/autoload/ale/engine.vim b/autoload/ale/engine.vim index c778f253..49cc2a9a 100644 --- a/autoload/ale/engine.vim +++ b/autoload/ale/engine.vim @@ -288,6 +288,11 @@ function! ale#engine#FixLocList(buffer, linter, loclist) abort let l:item.detail = l:old_item.detail endif + " Pass on a col_length key if set, used for highlights. + if has_key(l:old_item, 'end_col') + let l:item.end_col = str2nr(l:old_item.end_col) + endif + if l:item.lnum == 0 " When errors appear at line 0, put them at line 1 instead. let l:item.lnum = 1 diff --git a/autoload/ale/highlight.vim b/autoload/ale/highlight.vim index f3a479e3..b51e5b2d 100644 --- a/autoload/ale/highlight.vim +++ b/autoload/ale/highlight.vim @@ -86,7 +86,7 @@ function! ale#highlight#UpdateHighlights() abort let l:col = l:item.col let l:group = l:item.type ==# 'E' ? 'ALEError' : 'ALEWarning' let l:line = l:item.lnum - let l:size = 1 + let l:size = has_key(l:item, 'end_col') ? l:item.end_col - l:col : 1 " Rememeber the match ID for the item. " This ID will be used to preserve loclist items which are set diff --git a/test/test_highlight_placement.vader b/test/test_highlight_placement.vader index 25c98784..e43b0dc1 100644 --- a/test/test_highlight_placement.vader +++ b/test/test_highlight_placement.vader @@ -137,3 +137,16 @@ Execute(Only ALE highlights should be restored when buffers are restored): " Only our matches should appear again. AssertEqual 1, len(getmatches()), 'The highlights weren''t set again!' + +Execute(Higlight end columns should set an appropriate size): + call ale#highlight#SetHighlights(bufnr('%'), [ + \ {'bufnr': bufnr('%'), 'type': 'E', 'lnum': 3, 'col': 2, 'end_col': 5}, + \ {'bufnr': bufnr('%'), 'type': 'W', 'lnum': 4, 'col': 1, 'end_col': 5}, + \]) + + AssertEqual + \ [ + \ {'group': 'ALEError', 'id': 15, 'priority': 10, 'pos1': [3, 2, 3]}, + \ {'group': 'ALEWarning', 'id': 16, 'priority': 10, 'pos1': [4, 1, 4]}, + \ ], + \ getmatches() diff --git a/test/test_loclist_corrections.vader b/test/test_loclist_corrections.vader index 281f6787..8e01dfbc 100644 --- a/test/test_loclist_corrections.vader +++ b/test/test_loclist_corrections.vader @@ -128,3 +128,39 @@ Execute(FixLocList should convert line and column numbers correctly): \ {'name': 'foobar'}, \ [{'text': 'a', 'lnum': '010', 'col': '010'}], \ ) + +Execute(FixLocList should pass on col_length values): + " The numbers should be 10, not 8 as octals. + AssertEqual + \ [ + \ { + \ 'text': 'a', + \ 'lnum': 10, + \ 'col': 10, + \ 'end_col': 12, + \ 'bufnr': bufnr('%'), + \ 'vcol': 0, + \ 'type': 'E', + \ 'nr': -1, + \ 'linter_name': 'foobar', + \ }, + \ { + \ 'text': 'a', + \ 'lnum': 10, + \ 'col': 11, + \ 'end_col': 12, + \ 'bufnr': bufnr('%'), + \ 'vcol': 0, + \ 'type': 'E', + \ 'nr': -1, + \ 'linter_name': 'foobar', + \ }, + \], + \ ale#engine#FixLocList( + \ bufnr('%'), + \ {'name': 'foobar'}, + \ [ + \ {'text': 'a', 'lnum': '010', 'col': '010', 'end_col': '012'}, + \ {'text': 'a', 'lnum': '010', 'col': '011', 'end_col': 12}, + \ ], + \ ) |