summaryrefslogtreecommitdiff
path: root/autoload
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2017-08-20 15:59:18 +0100
committerw0rp <devw0rp@gmail.com>2017-08-20 15:59:27 +0100
commit456378cb53dbf38ff0077b8f41894bbdc7c9671e (patch)
tree9b4cd1a93f6bbce0bcceb40a47050f7edc3e513f /autoload
parent47e681529bbb98410d31bc0659b4b81c6fc7a97c (diff)
downloadale-456378cb53dbf38ff0077b8f41894bbdc7c9671e.zip
#653 - Jump to the position which Vim does not jump to for moving from quickfix/loclist items to other buffers
Diffstat (limited to 'autoload')
-rw-r--r--autoload/ale/events.vim30
1 files changed, 30 insertions, 0 deletions
diff --git a/autoload/ale/events.vim b/autoload/ale/events.vim
index c84954c1..2ee7f86a 100644
--- a/autoload/ale/events.vim
+++ b/autoload/ale/events.vim
@@ -60,10 +60,40 @@ function! s:HitReturn(...) abort
if get(split(l:output, "\n"), -1, '') =~# '^E92[456]'
call ale#util#FeedKeys("\<CR>", 'n')
+
+ " If we hit one of the errors and cleared it, then Vim didn't
+ " move to the position we wanted. Change the position to the one
+ " the user selected.
+ if exists('g:ale_list_window_selection')
+ let l:pos = getcurpos()
+ let [l:pos[1], l:pos[2]] = g:ale_list_window_selection
+ call setpos('.', l:pos)
+ endif
endif
endif
+
+ " Always clear the last selection when trying to cancel the errors above
+ " here. This prevents us from remembering invalid positions.
+ unlet! g:ale_list_window_selection
endfunction
function! ale#events#BufWinLeave() abort
call timer_start(0, function('s:HitReturn'))
endfunction
+
+" Grab the position for a problem from the loclist or quickfix windows
+" when moving through selections. This selection will be remembered and
+" set as the position when jumping to an error in another file.
+function! ale#events#ParseLoclistWindowItemPosition() abort
+ " Parses lines like
+ " test.txt|72 col 5 error| ...
+ " test.txt|72| ...
+ let l:match = matchlist(getline('.'), '\v^[^|]+\|(\d+)( [^ ]+ )?(\d*)')
+
+ if !empty(l:match)
+ let g:ale_list_window_selection = [
+ \ l:match[1] + 0,
+ \ max([l:match[3] + 0, 1]),
+ \]
+ endif
+endfunction