diff --git a/autoload/EasyMotion.vim b/autoload/EasyMotion.vim index a032b4d..8aafef9 100644 --- a/autoload/EasyMotion.vim +++ b/autoload/EasyMotion.vim @@ -72,6 +72,7 @@ function! EasyMotion#reset() " backward find motion is exclusive let s:current = { \ 'is_operator' : 0, + \ 'is_search' : 0, \ 'dot_repeat_target_cnt' : 0, \ 'dot_prompt_user_cnt' : 0, \ 'changedtick' : 0, @@ -386,7 +387,8 @@ function! s:findMotion(num_strokes, direction) "{{{ let s:current.is_operator = mode(1) ==# 'no' ? 1: 0 " store cursor pos because 'n' key find motion could be jump to offscreen let s:current.original_position = [line('.'), col('.')] - let s:flag.regexp = a:num_strokes == -1 ? 1 : 0 + let s:current.is_search = a:num_strokes == -1 ? 1: 0 + let s:flag.regexp = a:num_strokes == -1 ? 1 : 0 " TODO: remove? if g:EasyMotion_add_search_history && a:num_strokes == -1 let s:previous['input'] = @/ @@ -432,7 +434,8 @@ function! s:convertRegep(input) "{{{ let re = s:convertSmartsign(re, a:input) endif - let case_flag = EasyMotion#helper#should_use_smartcase(a:input) ? '\c' : '\C' + let case_flag = EasyMotion#helper#should_case_sensitive( + \ a:input, s:current.is_search) ? '\c' : '\C' let re = case_flag . re return re endfunction "}}} diff --git a/autoload/EasyMotion/command_line.vim b/autoload/EasyMotion/command_line.vim index 8b141d8..61a77cf 100644 --- a/autoload/EasyMotion/command_line.vim +++ b/autoload/EasyMotion/command_line.vim @@ -138,10 +138,13 @@ endfunction "}}} function! s:search.on_char() "{{{ if s:num_strokes == -1 let re = s:search.getline() + if EasyMotion#helper#should_case_sensitive(re, 1) + let case_flag = '\c' + else + let case_flag = '\C' + endif + let re .= case_flag if g:EasyMotion_inc_highlight - let case_flag = EasyMotion#helper#should_use_smartcase(re) ? - \ '\c' : '\C' - let re .= case_flag call s:inc_highlight(re) endif if g:EasyMotion_off_screen_search diff --git a/autoload/EasyMotion/helper.vim b/autoload/EasyMotion/helper.vim index 4c06be4..8e2fbdb 100644 --- a/autoload/EasyMotion/helper.vim +++ b/autoload/EasyMotion/helper.vim @@ -1,7 +1,7 @@ "============================================================================= " FILE: autoload/EasyMotion/helper.vim " AUTHOR: haya14busa -" Last Change: 25 Jan 2014. +" Last Change: 06 Feb 2014. " License: MIT license {{{ " Permission is hereby granted, free of charge, to any person obtaining " a copy of this software and associated documentation files (the @@ -62,12 +62,22 @@ function! EasyMotion#helper#is_folded(line) "{{{ \ (g:EasyMotion_skipfoldedline == 1 || \ a:line != foldclosed(a:line)) endfunction "}}} -function! EasyMotion#helper#should_use_smartcase(input) "{{{ - if g:EasyMotion_smartcase == 0 - return 0 +function! EasyMotion#helper#should_case_sensitive(input, is_search) "{{{ + if !a:is_search + if g:EasyMotion_smartcase == 0 + return 0 + else + " return 1 if input didn't match uppercase letter + return match(a:input, '\u') == -1 + endif endif - " return 1 if input didn't match uppercase letter - return match(a:input, '\u') == -1 + + if (g:EasyMotion_smartcase == 1 && match(a:input, '\u') == -1) || + \ (&ignorecase && &smartcase && match(a:input, '\u') == -1) || + \ (&ignorecase && !&smartcase) + return 1 + endif + return 0 endfunction "}}} " Migemo {{{