mirror of
https://github.com/junegunn/vim-easy-align.git
synced 2025-11-12 03:43:48 -05:00
Disallow non-printable character input
This commit is contained in:
@@ -130,7 +130,7 @@ function! s:echon_(tokens)
|
|||||||
endtry
|
endtry
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! s:echon(l, n, r, d, o)
|
function! s:echon(l, n, r, d, o, warn)
|
||||||
let tokens = [
|
let tokens = [
|
||||||
\ ['Function', ':EasyAlign'],
|
\ ['Function', ':EasyAlign'],
|
||||||
\ ['ModeMsg', get(s:mode_labels, a:l, a:l)],
|
\ ['ModeMsg', get(s:mode_labels, a:l, a:l)],
|
||||||
@@ -143,6 +143,7 @@ function! s:echon(l, n, r, d, o)
|
|||||||
\ [['Identifier', a:d == ' ' ? '\ ' : (a:d == '\' ? '\\' : a:d)]])
|
\ [['Identifier', a:d == ' ' ? '\ ' : (a:d == '\' ? '\\' : a:d)]])
|
||||||
if a:r == -1 | call add(tokens, ['Comment', ')']) | endif
|
if a:r == -1 | call add(tokens, ['Comment', ')']) | endif
|
||||||
call add(tokens, ['Statement', empty(a:o) ? '' : ' '.string(a:o)])
|
call add(tokens, ['Statement', empty(a:o) ? '' : ' '.string(a:o)])
|
||||||
|
call add(tokens, ['WarningMsg', a:warn])
|
||||||
|
|
||||||
call s:echon_(tokens)
|
call s:echon_(tokens)
|
||||||
endfunction
|
endfunction
|
||||||
@@ -567,9 +568,11 @@ function! s:interactive(modes, vis, opts)
|
|||||||
let opts = s:compact_options(a:opts)
|
let opts = s:compact_options(a:opts)
|
||||||
let vals = deepcopy(s:option_values)
|
let vals = deepcopy(s:option_values)
|
||||||
let regx = 0
|
let regx = 0
|
||||||
|
let warn = ''
|
||||||
|
|
||||||
while 1
|
while 1
|
||||||
call s:echon(mode, n, -1, '', opts)
|
call s:echon(mode, n, -1, '', opts, warn)
|
||||||
|
let warn = ''
|
||||||
|
|
||||||
let c = getchar()
|
let c = getchar()
|
||||||
let ch = nr2char(c)
|
let ch = nr2char(c)
|
||||||
@@ -638,8 +641,10 @@ function! s:interactive(modes, vis, opts)
|
|||||||
let s:prev_echon_len = len(prompt . ch)
|
let s:prev_echon_len = len(prompt . ch)
|
||||||
break
|
break
|
||||||
endif
|
endif
|
||||||
else
|
elseif ch =~ '[[:print:]]'
|
||||||
break
|
break
|
||||||
|
else
|
||||||
|
let warn = ' - Invalid character'
|
||||||
endif
|
endif
|
||||||
endwhile
|
endwhile
|
||||||
return [mode, n, ch, s:normalize_options(opts), regx]
|
return [mode, n, ch, s:normalize_options(opts), regx]
|
||||||
@@ -828,6 +833,6 @@ function! s:align(bang, first_line, last_line, expr)
|
|||||||
\ )
|
\ )
|
||||||
call extend(copts, { 'm': aseq_str })
|
call extend(copts, { 'm': aseq_str })
|
||||||
endif
|
endif
|
||||||
call s:echon('', n, regexp, ch, copts)
|
call s:echon('', n, regexp, ch, copts, '')
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user