Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- " Cache a possibly filled location list for a hiding buffer.
- " Check if there is a non-empty list for the current buffer.
- " Stores the list to the cache and empty the original one.
- " The location window will be closed.
- "
- " Arguments:
- " buffer - buffer to create the cache for
- "
- function! utils#location#cache_location_list(buffer) abort
- if get(g:, 'dynamic_location_list_disable', v:false) | return | endif
- let l:location_list = getloclist(0)
- " Check if something exist to cache.
- if len(l:location_list) > 0
- let s:map_buffer_location_list[a:buffer] = l:location_list " Cache the location list for the buffer.
- call setloclist(0, []) " Remove since else it remains for the next buffer.
- lclose " Close the empty window (will be possibly reopened on restore for new buffer).
- endif
- endfunction
- " Restore a possibly cached location list for a new displayed buffer.
- " Check the cache if a location list has been stored for the buffer.
- " If so it fills the list with the stored one and opens the window.
- " The cache entry will be removed.
- "
- " Arguments:
- " buffer - buffer to restore the cache for
- "
- function! utils#location#restore_location_list(buffer) abort
- if get(g:, 'dynamic_location_list_disable', v:false) | return | endif
- " Check cache for the entered buffer.
- if has_key(s:map_buffer_location_list, a:buffer)
- call setloclist(0, s:map_buffer_location_list[a:buffer]) " Restore the location list from cache.
- unlet s:map_buffer_location_list[a:buffer] " Remove cache to avoid reloading.
- lopen " Open the filled window.
- wincmd p " Jump back from location list to actual window.
- endif
- endfunction
Add Comment
Please, Sign In to add comment