Fix #1661 - Do not use :edit when jumping inside of a file

This commit is contained in:
w0rp 2018-06-21 21:20:54 +01:00
parent 22533f2c1f
commit 8bca073763
No known key found for this signature in database
GPG Key ID: 0FC1ECAA8C81CD83
2 changed files with 26 additions and 1 deletions

View File

@ -56,7 +56,10 @@ function! ale#util#Open(filename, line, column, options) abort
if get(a:options, 'open_in_tab', 0)
call ale#util#Execute('tabedit ' . fnameescape(a:filename))
else
call ale#util#Execute('edit ' . fnameescape(a:filename))
" Open another file only if we need to.
if bufnr(a:filename) isnot bufnr('')
call ale#util#Execute('edit ' . fnameescape(a:filename))
endif
endif
call cursor(a:line, a:column)

View File

@ -187,6 +187,28 @@ Execute(Other files should be jumped to for LSP definition responses):
AssertEqual [3, 7], getpos('.')[1:2]
AssertEqual {}, ale#definition#GetMap()
Execute(Locations inside the same file should be jumped to without using :edit):
call ale#definition#SetMap({3: {'open_in_tab': 0}})
call ale#definition#HandleLSPResponse(
\ 1,
\ {
\ 'id': 3,
\ 'result': {
\ 'uri': ale#path#ToURI(ale#path#Simplify(expand('%:p'))),
\ 'range': {
\ 'start': {'line': 2, 'character': 7},
\ },
\ },
\ }
\)
AssertEqual
\ [
\ ],
\ g:expr_list
AssertEqual [3, 7], getpos('.')[1:2]
AssertEqual {}, ale#definition#GetMap()
Execute(Other files should be jumped to in tabs for LSP definition responses):
call ale#definition#SetMap({3: {'open_in_tab': 1}})
call ale#definition#HandleLSPResponse(