Skip to content

Commit b9b334b

Browse files
authored
Merge pull request #385 from Andrei-Stepanov/line_jump_search_highlight
Update 'line' extension to act as Vim search pattern.
2 parents e346ae1 + 52f2aa9 commit b9b334b

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

autoload/ctrlp.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1201,7 +1201,7 @@ fu! s:AcceptSelection(action)
12011201
let type = exttype == 'dict' ? exttype : 'list'
12021202
en
12031203
en
1204-
let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr }]
1204+
let actargs = type == 'dict' ? [{ 'action': md, 'line': line, 'icr': icr, 'input': str}]
12051205
\ : [md, line]
12061206
cal call(actfunc, actargs)
12071207
endf

autoload/ctrlp/line.vim

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ let g:loaded_ctrlp_line = 1
1313
cal add(g:ctrlp_ext_vars, {
1414
\ 'init': 'ctrlp#line#init(s:crbufnr)',
1515
\ 'accept': 'ctrlp#line#accept',
16+
\ 'act_farg' : 'dict',
1617
\ 'lname': 'lines',
1718
\ 'sname': 'lns',
1819
\ 'type': 'tabe',
@@ -50,11 +51,17 @@ fu! ctrlp#line#init(bufnr)
5051
retu lines
5152
endf
5253

53-
fu! ctrlp#line#accept(mode, str)
54-
let info = matchlist(a:str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
54+
fu! ctrlp#line#accept(dict)
55+
let mode = a:dict['action']
56+
let str = a:dict['line']
57+
let input = a:dict['input']
58+
let info = matchlist(str, '\t|[^|]\+|\(\d\+\):\(\d\+\)|$')
5559
let bufnr = str2nr(get(info, 1))
5660
if bufnr
57-
cal ctrlp#acceptfile(a:mode, bufnr, get(info, 2))
61+
cal ctrlp#acceptfile(mode, bufnr, get(info, 2))
62+
let @/ = input
63+
call search(input, 'c')
64+
call histadd("search", input)
5865
en
5966
endf
6067

0 commit comments

Comments
 (0)