Skip to content

Commit

Permalink
add filtering displayed text function
Browse files Browse the repository at this point in the history
  • Loading branch information
kamykn committed Apr 15, 2020
1 parent 68e2847 commit 8e437e4
Showing 1 changed file with 30 additions and 3 deletions.
33 changes: 30 additions & 3 deletions autoload/spelunker/get_buffer.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,34 @@ set cpo&vim

function! spelunker#get_buffer#all()
let l:window_text_list = getline(1, '$')
let l:window_text = join(l:window_text_list, "\n")
call s:filter(l:window_text_list)
endfunction

function! spelunker#get_buffer#displayed()
let l:current_line = line("w0")
let l:end_line = line("w$")

let l:window_text_list = []

while 1
if foldclosed(l:current_line) > 0
let l:current_line = foldclosedend(l:current_line) + 1
endif

if l:current_line > l:end_line
break
endif

call add(l:window_text_list, getline(l:current_line))

let l:current_line = l:current_line + 1
endwhile

call s:filter(l:window_text_list)
endfunction

function! s:filter(window_text_list)
let l:window_text = join(a:window_text_list, "\n")

let l:window_text = s:filter_uri(l:window_text)
let l:window_text = s:filter_back_quoted_string(l:window_text)
Expand All @@ -14,7 +41,7 @@ function! spelunker#get_buffer#all()
endfunction

function! s:filter_uri(text)
if g:spelunker_disable_url = 1
if g:spelunker_disable_url == 1
return
endif

Expand All @@ -25,7 +52,7 @@ endfunction
function! s:filter_back_quoted_string(text)
" for shell command
" ex) `ls -la`
if g:spelunker_disable_back_quoted_string = 1
if g:spelunker_disable_back_quoted_string == 1
return
endif

Expand Down

0 comments on commit 8e437e4

Please sign in to comment.