summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorw0rp <devw0rp@gmail.com>2021-06-29 11:53:11 +0100
committerw0rp <devw0rp@gmail.com>2021-06-29 11:53:11 +0100
commit7862633d9d0e35157d54ad1487bd5a73c618fc7f (patch)
tree5936b02921846c22d063e0a117241113c961d764
parenta4ba421803d030a8967ede111ce921d439aa5fbb (diff)
downloadale-7862633d9d0e35157d54ad1487bd5a73c618fc7f.zip
When repeating selections, jump to the last selected item
-rw-r--r--autoload/ale/preview.vim15
1 files changed, 13 insertions, 2 deletions
diff --git a/autoload/ale/preview.vim b/autoload/ale/preview.vim
index 8b94aa7a..1aca03ea 100644
--- a/autoload/ale/preview.vim
+++ b/autoload/ale/preview.vim
@@ -1,7 +1,7 @@
" Author: w0rp <devw0rp@gmail.com>
" Description: Preview windows for showing whatever information in.
-if !has_key(s:, 'last__list')
+if !has_key(s:, 'last_list')
let s:last_list = []
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_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.
call ale#preview#SetLastSelection(a:item_list, l:options)
endfunction
@@ -101,12 +108,16 @@ endfunction
function! s:Open(open_in) abort
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)
return
endif
+ " Remember an index to jump to when repeating a selection.
+ let s:last_options.jump_to_index = l:index
+
:q!
call ale#util#Open(