Skip to content

Commit

Permalink
fix is_enabled() functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kamykn committed Nov 21, 2019
1 parent ea86b27 commit 59e3d9c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 12 deletions.
4 changes: 2 additions & 2 deletions autoload/spelunker.vim
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,11 @@ function! spelunker#toggle_buffer()
endfunction

function s:clear_matches()
if spelunker#toggle#is_enabled_buffer() == 1
if spelunker#toggle#is_enabled_buffer() == 0
call spelunker#matches#clear_current_buffer_matches()
endif

if spelunker#toggle#is_enabled_global() == 1
if spelunker#toggle#is_enabled_global() == 0
call spelunker#matches#clear_matches()
endif
endfunction
Expand Down
33 changes: 23 additions & 10 deletions autoload/spelunker/toggle.vim
Original file line number Diff line number Diff line change
Expand Up @@ -41,27 +41,40 @@ function! spelunker#toggle#toggle_buffer()
endfunction

function! spelunker#toggle#init_buffer(mode, is_enabled)
if a:is_enabled == 0
if a:is_enabled == 1
if a:mode == 1 " for global
call spelunker#check()
elseif a:mode == 2 " for buffer
call spelunker#check_displayed_words()
endif
elseif a:is_enabled == 0
if a:mode == 1 " for global
call spelunker#matches#clear_matches()
elseif a:mode == 2 " for buffer
call spelunker#matches#clear_current_buffer_matches()
endif
elseif a:is_enabled == 1
if g:spelunker_check_type == g:spelunker_check_type_buf_lead_write
call spelunker#check()
elseif g:spelunker_check_type == g:spelunker_check_type_cursor_hold
call spelunker#check_displayed_words()
endif
endif
endfunction

function! spelunker#toggle#is_enabled()
if spelunker#toggle#is_enabled_buffer() == 1 || spelunker#toggle#is_enabled_global() == 1
return 1
if !exists('b:enable_spelunker_vim')
if spelunker#toggle#is_enabled_global() == 1
return 1
endif

return 0
else
" b:enable_spelunker_vimがあればbuffer優先
if spelunker#toggle#is_enabled_buffer() == 0
return 0
endif
endif

return 0
if spelunker#toggle#is_enabled_global() == 0
return 0
endif

return 1
endfunction

function! spelunker#toggle#is_enabled_global()
Expand Down

0 comments on commit 59e3d9c

Please sign in to comment.