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'
|
let s:search.highlights.prompt = 'Question'
|
||||||
|
|
||||||
" Add Module: {{{
|
" 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('Cancel')
|
||||||
call s:search.connect('Redraw')
|
call s:search.connect('Redraw')
|
||||||
call s:search.connect('Delete')
|
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:num_strokes = a:num_strokes
|
||||||
|
|
||||||
let s:prompt_base = s:getPromptMessage(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
|
" Screen: cursor position, first and last line
|
||||||
let s:orig_pos = getpos('.')
|
let s:orig_pos = getpos('.')
|
||||||
|
@ -26,7 +26,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:make(...)
|
function! s:make(...)
|
||||||
let result = deepcopy(s:base)
|
let result = deepcopy(s:base)
|
||||||
let result.set_prompt(get(a:, 1, ":"))
|
call result.set_prompt(get(a:, 1, ":"))
|
||||||
call result.connect(result, "_")
|
call result.connect(result, "_")
|
||||||
return result
|
return result
|
||||||
endfunction
|
endfunction
|
||||||
@ -46,6 +46,7 @@ let s:base = {
|
|||||||
\ "tap_key" : "",
|
\ "tap_key" : "",
|
||||||
\ "exit" : 0,
|
\ "exit" : 0,
|
||||||
\ "keymapping" : {},
|
\ "keymapping" : {},
|
||||||
|
\ "suffix" : "",
|
||||||
\ },
|
\ },
|
||||||
\ "highlights" : {
|
\ "highlights" : {
|
||||||
\ "prompt" : "NONE",
|
\ "prompt" : "NONE",
|
||||||
@ -139,6 +140,16 @@ function! s:base.get_prompt()
|
|||||||
endfunction
|
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, ...)
|
function! s:base.insert(word, ...)
|
||||||
if a:0
|
if a:0
|
||||||
call self.line.set(a:1)
|
call self.line.set(a:1)
|
||||||
@ -317,7 +328,7 @@ function! s:base._execute(command)
|
|||||||
execute a:command
|
execute a:command
|
||||||
catch
|
catch
|
||||||
echohl ErrorMsg
|
echohl ErrorMsg
|
||||||
echo matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze')
|
echom matchstr(v:exception, 'Vim\((\w*)\)\?:\zs.*\ze')
|
||||||
echohl None
|
echohl None
|
||||||
call self.callevent("on_execute_failed")
|
call self.callevent("on_execute_failed")
|
||||||
finally
|
finally
|
||||||
@ -346,7 +357,7 @@ function! s:base._main(...)
|
|||||||
call self.callevent("on_char")
|
call self.callevent("on_char")
|
||||||
endwhile
|
endwhile
|
||||||
catch
|
catch
|
||||||
echohl ErrorMsg | echo v:throwpoint . " " . v:exception | echohl None
|
echohl ErrorMsg | echom v:throwpoint . " " . v:exception | echohl None
|
||||||
return -1
|
return -1
|
||||||
finally
|
finally
|
||||||
call self._finish()
|
call self._finish()
|
||||||
@ -361,21 +372,34 @@ function! s:base._finish()
|
|||||||
endfunction
|
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)
|
function! s:_echo_cmdline(cmdline)
|
||||||
call s:redraw()
|
call a:cmdline.redraw()
|
||||||
execute "echohl" a:cmdline.highlights.prompt
|
execute "echohl" a:cmdline.highlights.prompt
|
||||||
echon a:cmdline.get_prompt()
|
call s:echon(a:cmdline.get_prompt())
|
||||||
echohl NONE
|
echohl NONE
|
||||||
echon a:cmdline.backward()
|
call s:echon(a:cmdline.backward())
|
||||||
if empty(a:cmdline.line.pos_word())
|
if empty(a:cmdline.line.pos_word())
|
||||||
execute "echohl" a:cmdline.highlights.cursor
|
execute "echohl" a:cmdline.highlights.cursor
|
||||||
echon ' '
|
call s:echon(' ')
|
||||||
else
|
else
|
||||||
execute "echohl" a:cmdline.highlights.cursor_on
|
execute "echohl" a:cmdline.highlights.cursor_on
|
||||||
echon a:cmdline.line.pos_word()
|
call s:echon(a:cmdline.line.pos_word())
|
||||||
endif
|
endif
|
||||||
echohl NONE
|
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
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
@ -422,10 +446,15 @@ function! s:base._get_keymapping()
|
|||||||
return extend(extend(result, self.variables.keymapping), self.keymapping())
|
return extend(extend(result, self.variables.keymapping), self.keymapping())
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
function! s:_redraw()
|
||||||
function! s:redraw()
|
" normal! :
|
||||||
redraw
|
redraw
|
||||||
echo ""
|
" echo ""
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
function! s:base.redraw()
|
||||||
|
call s:_redraw()
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
|
@ -3,6 +3,19 @@ let s:save_cpo = &cpo
|
|||||||
set cpo&vim
|
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)
|
function! s:_is_input_enter(cmdline)
|
||||||
return a:cmdline.is_input("\<CR>")
|
return a:cmdline.is_input("\<CR>")
|
||||||
\ || a:cmdline.is_input("\<NL>")
|
\ || a:cmdline.is_input("\<NL>")
|
||||||
@ -36,28 +49,18 @@ function! s:make()
|
|||||||
endfunction
|
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 = deepcopy(s:module)
|
||||||
let s:search.prefix = "/"
|
let s:search.prefix = "/"
|
||||||
|
|
||||||
|
|
||||||
function! s:search.execute(cmdline)
|
function! s:search.execute(cmdline)
|
||||||
" let cmd = printf("call feedkeys(\"%s%s\<CR>\", 'n')", self.prefix, a:cmdline.getline())
|
call s:silent_feedkeys(":call histdel('/', -1)\<CR>", "remove_hist", "n")
|
||||||
let cmd = printf("call search('%s')", a:cmdline.getline())
|
let cmd = printf("call s:silent_feedkeys(\"%s%s\<CR>\", 'search', 'n')", self.prefix, a:cmdline.getline())
|
||||||
call a:cmdline.execute(cmd)
|
execute cmd
|
||||||
let @/ = a:cmdline.getline()
|
" let cmd = printf("call search('%s')", a:cmdline.getline())
|
||||||
let &hlsearch = &hlsearch
|
" call a:cmdline.execute(cmd)
|
||||||
call feedkeys(":set hlsearch | set incsearch\<CR>", 'n')
|
" let @/ = a:cmdline.getline()
|
||||||
|
" call s:silent_feedkeys(":let &hlsearch = &hlsearch\<CR>", "hlsearch", "n")
|
||||||
endfunction
|
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
|
return index(self.chars, a:char) >= 0
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|
||||||
function! s:module.on_char_pre(cmdline)
|
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
|
\ && a:cmdline.char() == a:cmdline.variables.input
|
||||||
call a:cmdline.setchar("", 0)
|
call a:cmdline.setchar("", 0)
|
||||||
endif
|
endif
|
||||||
@ -30,7 +30,7 @@ endfunction
|
|||||||
|
|
||||||
function! s:make_special_chars()
|
function! s:make_special_chars()
|
||||||
let module = s:make([])
|
let module = s:make([])
|
||||||
function! module.is_insert(char)
|
function! module.is_no_insert(char)
|
||||||
return char2nr(a:char) == 128 || char2nr(a:char) < 27
|
return char2nr(a:char) == 128 || char2nr(a:char) < 27
|
||||||
endfunction
|
endfunction
|
||||||
return module
|
return module
|
||||||
|
@ -29,9 +29,8 @@ function! s:module.on_leave(cmdline)
|
|||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:module.redraw(...)
|
function! s:module.redraw(cmdline)
|
||||||
redraw
|
call a:cmdline.redraw()
|
||||||
echo ""
|
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:make()
|
function! s:make()
|
||||||
|
Loading…
Reference in New Issue
Block a user