Check matchlist's result

This commit is contained in:
Kien N 2012-04-14 13:44:05 +07:00
parent f534dab9bd
commit 43915113db
7 changed files with 11 additions and 3 deletions

View File

@ -889,7 +889,9 @@ endf
fu! s:OpenMulti()
if !exists('s:marked') || s:opmul == '0' || !s:ispath | retu | en
" Get the options
let [nr, md, ucr] = matchlist(s:opmul, '\v^(\d+)=(\w)=(\w)=$')[1:3]
let opts = matchlist(s:opmul, '\v^(\d+)=(\w)=(\w)=$')
if opts == [] | retu | en
let [nr, md, ucr] = opts[1:3]
if s:argmap
let md = s:argmaps(md)
if md == 'cancel' | retu | en

View File

@ -61,7 +61,8 @@ fu! s:setentries()
endf
fu! s:parts(str)
retu matchlist(a:str, '\v([^\t]+)\t(.*)$')[1:2]
let mlist = matchlist(a:str, '\v([^\t]+)\t(.*)$')
retu mlist != [] ? mlist[1:2] : ['', '']
endf
fu! s:process(entries, type)

View File

@ -222,6 +222,7 @@ endf
fu! ctrlp#buffertag#accept(mode, str)
let vals = matchlist(a:str, '\v^[^\t]+\t+[^\t|]+\|(\d+)\:[^\t|]+\|(\d+)\|')
if vals == [] | retu | en
let [bufnm, linenr] = [fnamemodify(bufname(str2nr(vals[1])), ':p'), vals[2]]
cal ctrlp#acceptfile(a:mode, bufnm, linenr)
endf

View File

@ -71,6 +71,7 @@ endf
fu! ctrlp#changes#accept(mode, str)
let info = matchlist(a:str, '\t|\(\d\+\):[^|]\+|\(\d\+\):\(\d\+\)|$')
if info == [] | retu | en
let bufnr = str2nr(get(info, 1))
if bufnr
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'))

View File

@ -48,6 +48,7 @@ endf
fu! ctrlp#line#accept(mode, str)
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
if info == [] | retu | en
let [bufnr, linenr] = [str2nr(get(info, 1)), get(info, 2)]
if bufnr > 0
cal ctrlp#acceptfile(a:mode, fnamemodify(bufname(bufnr), ':p'), linenr)

View File

@ -41,6 +41,7 @@ endf
fu! ctrlp#quickfix#accept(mode, str)
let items = matchlist(a:str, '^\([^|]\+\ze\)|\(\d\+\):\(\d\+\)|')
if items == [] | retu | en
let [md, filpath] = [a:mode, fnamemodify(items[1], ':p')]
if empty(filpath) | retu | en
cal ctrlp#exit()

View File

@ -112,7 +112,8 @@ endf
fu! s:formatul(...)
let parts = matchlist(a:1,
\ '\v^\s+(\d+)\s+\d+\s+([^ ]+\s?[^ ]+|\d+\s\w+\s\w+)(\s*\d*)$')
retu parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
retu parts == [] ? '----'
\ : parts[2].' ['.parts[1].']'.( parts[3] != '' ? ' saved' : '' )
endf
" Public {{{1
fu! ctrlp#undo#init()