kien/ctrlp.vim — Issue #121: CtrlP incorrectly selects similarly called files 
Author: datanoise
Created: 2012-01-31 20:44:47+00:00
State: open

For example, a typical rails app has two files: Gemfile and Gemfile.lock. As soon you open Gemfile.lock file there is no way to open Gemfile anymore. The reason is that `bufnr()` function uses regexp expressions and uses the front part of the file name.

Please check this patch:

``` diff

diff --git a/autoload/ctrlp.vim b/autoload/ctrlp.vim
index 227ff99..db336c5 100644
--- a/autoload/ctrlp.vim
+++ b/autoload/ctrlp.vim
@@ -705,7 +705,7 @@ endf
fu! ctrlp#acceptfile(mode, matchstr, ...)
let [md, filpath] = [a:mode, fnamemodify(a:matchstr, ':p')]
cal s:PrtExit()
-	let [bufnr, tail] = [bufnr(filpath), s:tail()]
+	let [bufnr, tail] = [bufnr('^'.filpath.'$'), s:tail()]
if s:jmptobuf && bufnr > 0 && md =~ 'e\|t'
let [jmpb, bufwinnr] = [1, bufwinnr(bufnr)]
let buftab = s:jmptobuf > 1 ? s:buftab(bufnr, md) : [0, 0]
```