forked from github-mirrors/ale
When repeating selections, jump to the last selected item
This commit is contained in:
parent
a4ba421803
commit
7862633d9d
|
@ -1,7 +1,7 @@
|
||||||
" Author: w0rp <devw0rp@gmail.com>
|
" Author: w0rp <devw0rp@gmail.com>
|
||||||
" Description: Preview windows for showing whatever information in.
|
" Description: Preview windows for showing whatever information in.
|
||||||
|
|
||||||
if !has_key(s:, 'last__list')
|
if !has_key(s:, 'last_list')
|
||||||
let s:last_list = []
|
let s:last_list = []
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
@ -89,6 +89,13 @@ function! ale#preview#ShowSelection(item_list, ...) abort
|
||||||
let b:ale_preview_item_list = a:item_list
|
let b:ale_preview_item_list = a:item_list
|
||||||
let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer')
|
let b:ale_preview_item_open_in = get(l:options, 'open_in', 'current-buffer')
|
||||||
|
|
||||||
|
" Jump to an index for a previous selection, if set.
|
||||||
|
if has_key(l:options, 'jump_to_index')
|
||||||
|
let l:pos = getpos('.')
|
||||||
|
let l:pos[1] = l:options.jump_to_index + 1
|
||||||
|
call setpos('.', l:pos)
|
||||||
|
endif
|
||||||
|
|
||||||
" Remember preview state, so we can repeat it later.
|
" Remember preview state, so we can repeat it later.
|
||||||
call ale#preview#SetLastSelection(a:item_list, l:options)
|
call ale#preview#SetLastSelection(a:item_list, l:options)
|
||||||
endfunction
|
endfunction
|
||||||
|
@ -101,12 +108,16 @@ endfunction
|
||||||
|
|
||||||
function! s:Open(open_in) abort
|
function! s:Open(open_in) abort
|
||||||
let l:item_list = get(b:, 'ale_preview_item_list', [])
|
let l:item_list = get(b:, 'ale_preview_item_list', [])
|
||||||
let l:item = get(l:item_list, getpos('.')[1] - 1, {})
|
let l:index = getpos('.')[1] - 1
|
||||||
|
let l:item = get(l:item_list, l:index, {})
|
||||||
|
|
||||||
if empty(l:item)
|
if empty(l:item)
|
||||||
return
|
return
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
" Remember an index to jump to when repeating a selection.
|
||||||
|
let s:last_options.jump_to_index = l:index
|
||||||
|
|
||||||
:q!
|
:q!
|
||||||
|
|
||||||
call ale#util#Open(
|
call ale#util#Open(
|
||||||
|
|
Loading…
Reference in New Issue