diff --git a/autoload/spelunker/get_buffer.vim b/autoload/spelunker/get_buffer.vim index 8e710da..4e6c1eb 100644 --- a/autoload/spelunker/get_buffer.vim +++ b/autoload/spelunker/get_buffer.vim @@ -5,7 +5,7 @@ set cpo&vim function! spelunker#get_buffer#all() let l:window_text_list = getline(1, '$') - call s:filter(l:window_text_list) + return s:filter(l:window_text_list) endfunction function! spelunker#get_buffer#displayed() @@ -28,7 +28,7 @@ function! spelunker#get_buffer#displayed() let l:current_line = l:current_line + 1 endwhile - call s:filter(l:window_text_list) + return s:filter(l:window_text_list) endfunction function! s:filter(window_text_list) @@ -37,7 +37,7 @@ function! s:filter(window_text_list) let l:window_text = s:filter_uri(l:window_text) let l:window_text = s:filter_back_quoted_string(l:window_text) - echo l:window_text + return split(l:window_text, "\n") endfunction function! s:filter_uri(text) diff --git a/autoload/spelunker/spellbad.vim b/autoload/spelunker/spellbad.vim index 8d1b04e..6cb9919 100644 --- a/autoload/spelunker/spellbad.vim +++ b/autoload/spelunker/spellbad.vim @@ -9,21 +9,13 @@ let s:save_cpo = &cpo set cpo&vim " end_lineの指定がなければ1行のみ -function! spelunker#spellbad#get_spell_bad_list(start_line, end_line) +function! spelunker#spellbad#get_spell_bad_list(window_text_list) call spelunker#white_list#init_white_list() - let l:window_text_list = [] - if a:end_line >= 0 - let l:window_text_list = getline(a:start_line, a:end_line) - else - " 1行のみ - call add(l:window_text_list, getline(a:start_line)) - endif - " spellgood で対象から外れる場合もあるので、全部チェックする必要があり " NOTE: spellgood系操作でmatch_id_dictから消してあげたらチェック不要になる。 " ただし、match_id_dictをglobalにする必要あり - let l:word_list = s:get_word_list(l:window_text_list) + let l:word_list = s:get_word_list(a:window_text_list) let l:current_spell_setting = spelunker#get_current_spell_setting() setlocal spell diff --git a/autoload/spelunker/words.vim b/autoload/spelunker/words.vim index ef7f355..2ccc69b 100644 --- a/autoload/spelunker/words.vim +++ b/autoload/spelunker/words.vim @@ -139,7 +139,9 @@ endfunction function! spelunker#words#check() call spelunker#cases#reset_case_counter() - let l:spell_bad_list = spelunker#spellbad#get_spell_bad_list(1, '$') + let l:window_text_list = spelunker#get_buffer#all() + let l:spell_bad_list = spelunker#spellbad#get_spell_bad_list(l:window_text_list) + call spelunker#words#highlight(l:spell_bad_list) endfunction @@ -147,25 +149,8 @@ endfunction function! spelunker#words#check_display_area() call spelunker#cases#reset_case_counter() - let l:spell_bad_list = [] - let l:current_line = line("w0") - let l:end_line = line("w$") - - 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 - - " 折りたたみが無い行のみチェック - let l:tmp_spell_bad_list = spelunker#spellbad#get_spell_bad_list(l:current_line, -1) - let l:spell_bad_list = l:spell_bad_list + l:tmp_spell_bad_list - - let l:current_line = l:current_line + 1 - endwhile + let l:window_text_list = spelunker#get_buffer#displayed() + let l:spell_bad_list = spelunker#spellbad#get_spell_bad_list(l:window_text_list) " unique let l:spell_bad_list = filter(copy(l:spell_bad_list), 'index(l:spell_bad_list, v:val, v:key+1)==-1')