Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change regex to make g:ctrlp_by_filename work. #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions autoload/pymatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ def CtrlPPyMatch():
aregex = int(vim.eval('a:regex'))
spath = vim.eval('a:ispath')
crfile = vim.eval('a:crfile')
sep = vim.eval('s:sep')

if not vim.eval('exists("g:ctrlp_match_current_file")') and ispath and crfile:
items.remove(crfile)

rez = vim.eval('s:rez')


regex = ''
if aregex == 1:
regex = astr
Expand All @@ -29,7 +29,7 @@ def CtrlPPyMatch():
# If the string is longer that one character, append a mismatch
# expression to each character (except the last).
if len(lowAstr) > 1:
mismatch = ["[^" + c + "]*" for c in escaped[:-1]]
mismatch = ["[^" + sep + c + "]*" for c in escaped[:-1]]
regex = ''.join([c for pair in zip(escaped[:-1], mismatch) for c in pair])

# Append the last character in the string to the regex
Expand Down
11 changes: 6 additions & 5 deletions autoload/pymatcher.vim
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ if !has('python') && !has('python3')
endif

let s:plugin_path = escape(expand('<sfile>:p:h'), '\')
if has('win32')
let s:sep = '\\'
else
let s:sep = '/'
endif

if has('python3')
execute 'py3file ' . s:plugin_path . '/pymatcher.py'
Expand All @@ -31,11 +36,7 @@ function! pymatcher#PyMatch(items, str, limit, mmode, ispath, crfile, regex)

let s:matchregex = '\v\c'

if a:mmode == 'filename-only'
let s:matchregex .= '[\^\/]*'
endif

let s:matchregex .= s:regex
let s:matchregex .= (s:regex . '[^' . s:sep . ']*$')

call matchadd('CtrlPMatch', s:matchregex)

Expand Down