Fix unexpected message echoed
Problem: use `let` to call function instead of `call`... update vital-over close #115
This commit is contained in:
parent
0a35207598
commit
bef3e42328
@ -38,7 +38,7 @@ let s:search = s:cmdline.make()
|
||||
let s:search.highlights.prompt = 'Question'
|
||||
|
||||
" Add Module: {{{
|
||||
call s:search.connect(s:modules.get("Execute").make_no_execute())
|
||||
call s:search.connect('Execute')
|
||||
call s:search.connect('Cancel')
|
||||
call s:search.connect('Redraw')
|
||||
call s:search.connect('Delete')
|
||||
@ -169,7 +169,7 @@ function! EasyMotion#command_line#GetInput(num_strokes, prev, direction) "{{{
|
||||
let s:num_strokes = a:num_strokes
|
||||
|
||||
let s:prompt_base = s:getPromptMessage(a:num_strokes)
|
||||
let s:search.set_prompt(s:prompt_base)
|
||||
call s:search.set_prompt(s:prompt_base)
|
||||
|
||||
" Screen: cursor position, first and last line
|
||||
let s:orig_pos = getpos('.')
|
||||
|
@ -26,7 +26,7 @@ endfunction
|
||||
|
||||
function! s:make(...)
|
||||
let result = deepcopy(s:base)
|
||||
let result.set_prompt(get(a:, 1, ":"))
|
||||
call result.set_prompt(get(a:, 1, ":"))
|
||||
call result.connect(result, "_")
|
||||
return result
|
||||
endfunction
|
||||
@ -46,6 +46,7 @@ let s:base = {
|
||||
\ "tap_key" : "",
|
||||
\ "exit" : 0,
|
||||
\ "keymapping" : {},
|
||||
\ "suffix" : "",
|
||||
\ },
|
||||
\ "highlights" : {
|
||||
\ "prompt" : "NONE",
|
||||
@ -139,6 +140,16 @@ function! s:base.get_prompt()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:base.set_suffix(str)
|
||||
let self.variables.suffix = a:str
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:base.get_suffix()
|
||||
return self.variables.suffix
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:base.insert(word, ...)
|
||||
if a:0
|
||||
call self.line.set(a:1)
|
||||
@ -317,7 +328,7 @@ function! s:base._execute(command)
|
||||
execute a:command
|
||||
catch
|
||||
echohl ErrorMsg
|
||||
echo matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze')
|
||||
echom matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze')
|
||||
echohl None
|
||||
call self.callevent("on_execute_failed")
|
||||
finally
|
||||
@ -346,7 +357,7 @@ function! s:base._main(...)
|
||||
call self.callevent("on_char")
|
||||
endwhile
|
||||
catch
|
||||
echohl ErrorMsg | echo v:throwpoint . " " . v:exception | echohl None
|
||||
echohl ErrorMsg | echom v:throwpoint . " " . v:exception | echohl None
|
||||
return -1
|
||||
finally
|
||||
call self._finish()
|
||||
@ -361,21 +372,34 @@ function! s:base._finish()
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:suffix(left, suffix)
|
||||
let left_len = strdisplaywidth(a:left)
|
||||
let len = &columns - left_len % &columns
|
||||
let len = len + (&columns * (strdisplaywidth(a:suffix) > (len - 1))) - 1
|
||||
return printf("%" . len . "S", a:suffix)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:echon(expr)
|
||||
echon strtrans(a:expr)
|
||||
endfunction
|
||||
|
||||
function! s:_echo_cmdline(cmdline)
|
||||
call s:redraw()
|
||||
call a:cmdline.redraw()
|
||||
execute "echohl" a:cmdline.highlights.prompt
|
||||
echon a:cmdline.get_prompt()
|
||||
call s:echon(a:cmdline.get_prompt())
|
||||
echohl NONE
|
||||
echon a:cmdline.backward()
|
||||
call s:echon(a:cmdline.backward())
|
||||
if empty(a:cmdline.line.pos_word())
|
||||
execute "echohl" a:cmdline.highlights.cursor
|
||||
echon ' '
|
||||
call s:echon(' ')
|
||||
else
|
||||
execute "echohl" a:cmdline.highlights.cursor_on
|
||||
echon a:cmdline.line.pos_word()
|
||||
call s:echon(a:cmdline.line.pos_word())
|
||||
endif
|
||||
echohl NONE
|
||||
echon a:cmdline.forward()
|
||||
call s:echon(a:cmdline.forward())
|
||||
call s:echon(s:suffix(a:cmdline.get_prompt() . a:cmdline.getline() . repeat(" ", empty(a:cmdline.line.pos_word())), a:cmdline.get_suffix()))
|
||||
endfunction
|
||||
|
||||
|
||||
@ -422,10 +446,15 @@ function! s:base._get_keymapping()
|
||||
return extend(extend(result, self.variables.keymapping), self.keymapping())
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:redraw()
|
||||
function! s:_redraw()
|
||||
" normal! :
|
||||
redraw
|
||||
echo ""
|
||||
" echo ""
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:base.redraw()
|
||||
call s:_redraw()
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -3,6 +3,19 @@ let s:save_cpo = &cpo
|
||||
set cpo&vim
|
||||
|
||||
|
||||
function! s:silent_feedkeys(expr, name, ...)
|
||||
let mode = get(a:, 1, "m")
|
||||
let map = printf("<Plug>(%s)", a:name)
|
||||
if mode == "n"
|
||||
let command = "nnoremap"
|
||||
else
|
||||
let command = "nmap"
|
||||
endif
|
||||
execute command "<silent>" map printf("%s:nunmap %s<CR>", a:expr, map)
|
||||
call feedkeys(printf("\<Plug>(%s)", a:name))
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:_is_input_enter(cmdline)
|
||||
return a:cmdline.is_input("\<CR>")
|
||||
\ || a:cmdline.is_input("\<NL>")
|
||||
@ -36,28 +49,18 @@ function! s:make()
|
||||
endfunction
|
||||
|
||||
|
||||
let s:empty = deepcopy(s:module)
|
||||
|
||||
function! s:empty.execute(...)
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:make_no_execute()
|
||||
return deepcopy(s:empty)
|
||||
endfunction
|
||||
|
||||
|
||||
let s:search = deepcopy(s:module)
|
||||
let s:search.prefix = "/"
|
||||
|
||||
|
||||
function! s:search.execute(cmdline)
|
||||
" let cmd = printf("call feedkeys(\"%s%s\<CR>\", 'n')", self.prefix, a:cmdline.getline())
|
||||
let cmd = printf("call search('%s')", a:cmdline.getline())
|
||||
call a:cmdline.execute(cmd)
|
||||
let @/ = a:cmdline.getline()
|
||||
let &hlsearch = &hlsearch
|
||||
call feedkeys(":set hlsearch | set incsearch\<CR>", 'n')
|
||||
call s:silent_feedkeys(":call histdel('/', -1)\<CR>", "remove_hist", "n")
|
||||
let cmd = printf("call s:silent_feedkeys(\"%s%s\<CR>\", 'search', 'n')", self.prefix, a:cmdline.getline())
|
||||
execute cmd
|
||||
" let cmd = printf("call search('%s')", a:cmdline.getline())
|
||||
" call a:cmdline.execute(cmd)
|
||||
" let @/ = a:cmdline.getline()
|
||||
" call s:silent_feedkeys(":let &hlsearch = &hlsearch\<CR>", "hlsearch", "n")
|
||||
endfunction
|
||||
|
||||
|
||||
|
@ -8,13 +8,13 @@ let s:module = {
|
||||
\}
|
||||
|
||||
|
||||
function! s:module.is_insert(char)
|
||||
function! s:module.is_no_insert(char)
|
||||
return index(self.chars, a:char) >= 0
|
||||
endfunction
|
||||
|
||||
|
||||
function! s:module.on_char_pre(cmdline)
|
||||
if self.is_insert(a:cmdline.char())
|
||||
if self.is_no_insert(a:cmdline.char())
|
||||
\ && a:cmdline.char() == a:cmdline.variables.input
|
||||
call a:cmdline.setchar("", 0)
|
||||
endif
|
||||
@ -30,7 +30,7 @@ endfunction
|
||||
|
||||
function! s:make_special_chars()
|
||||
let module = s:make([])
|
||||
function! module.is_insert(char)
|
||||
function! module.is_no_insert(char)
|
||||
return char2nr(a:char) == 128 || char2nr(a:char) < 27
|
||||
endfunction
|
||||
return module
|
||||
|
@ -29,9 +29,8 @@ function! s:module.on_leave(cmdline)
|
||||
endif
|
||||
endfunction
|
||||
|
||||
function! s:module.redraw(...)
|
||||
redraw
|
||||
echo ""
|
||||
function! s:module.redraw(cmdline)
|
||||
call a:cmdline.redraw()
|
||||
endfunction
|
||||
|
||||
function! s:make()
|
||||
|
Loading…
Reference in New Issue
Block a user