Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Strange behavior when ConqueTerm window is open #195

Closed
skwp opened this Issue · 13 comments

2 participants

@skwp

Hi @kien I would love to debug this issue but I'm at a loss as to where to start. If I have ConqueTerm window open, when I hit something like :CtrlP some/dir/path, I get a broken looking controlp, with a "Press ENTER or type command" prompt. As I then type the name of the match, I start getting errors out of other plugins such as powerline/fugitive:

Error detected while processing function <SNR>187_PrtAdd..    <SNR>187_BuildPrompt..Powerline#Functions#fugitive#GetBranch..fugitive#statusline..<SNR>128_repo_head_ref:

as well as Can't open file ./.git/HEAD

This only happens when passing the path to CtrlP, every other CtrlP command works.

I'm happy to debug this myself if you can help me out by pointing me to where in the ctrlp code the :CtrlP [dir] is handled. Please note that :CtrlP by itself works fine, it's only the dir param that seems to break it, and only when ConqueTerm is open

Thanks!

@kien
Owner

ctrlp provides an option to rebuild its statuslines, g:ctrlp_status_func, which powerline uses. By the look of it, something triggers fugitive (script 128) to break, leading to its statusline feature breaking, which in turn breaks powerline and then finally ctrlp (script 187).

So before starting ctrlp with :CtrlP [dir], run :let g:ctrlp_status_func = {} and let me know if it fixes the problem. Also, run :echo g:ctrlp_status_func after you exit ctrlp and post the output here.

After the above, restart Vim, this time run :let g:ctrlp_log = 1 and then proceed to reproduce the problem. After creating a few error msgs, exit ctrlp and go to the cache directory (should be $HOME/.cache/ctrlp), open the ctrlp.log file and post its content here.

@kien
Owner

OK, I can't reproduce this with the combo conqueterm + ctrlp + powerline + fugitive. I use the settings for conqueterm and powerline found here.

Guess this will depend on you to track it down, then. The :CtrlP [dir] is handled with the SetWD function. With a [dir] argument, it should return at Line 4: cal ctrlp#setdir(a:1) | retu. It's odd though, because ctrlp#setdir is called later on anyway if you just use :CtrlP. Why doesn't it break then?

In any case, it's important to get all the error messages, especially the first ones that create the "Press ENTER or type command" prompt.

@skwp

Ran the let, it didn't fix the problem. Ran the echo and it echoed {} which I think is what you expected. Here's a bit of a play by play of the log. By the way, awesome logging feature. I'm gonna have to learn about this for my own plugins :)

  1. Open vim, and do a regular :CtrlP call. No errors shown in vim, however the log shows
Error detected while processing function <SNR>18_BMRemove:
line    9:
E329: No menu "ControlP (3) ~/dev/crowdcast/x3">d> _

This error appears when I escape out of the ctrlp prompt without opening a file. If I open a file

  1. Open up a ruby spec file and run conqueterm on it (using skwp/vim-ruby-conque plugin). It turns out if I open a regular conqueterm, no problem. But when I run one of those conques, I get the problem in step 3:

  2. Run :CtrlP app/models to get a directory based ctrlp. See the 'Press Enter' message in vim, no errors in log. Hit escape out of that prompt, see message in log:

Error detected while processing function ctrlp#init..<SNR>187_BuildPrompt..Powerline#Functions#fugitive#GetBranch..fugitive#statusline..<SNR>128_repo_head_ref:
line    1:
E484: Can't open file ./.git/HEAD
E684: list index out of range: 0
E15: Invalid expression: readfile(self.dir('HEAD'))[0]>>> _

After this, it's hard to describe what happens, but basically I can't really select any files from ctrlp as the prompt is messed up in this mode with the "Press Enter" message.

That was just a straight dump of what happened but now I will read your message and try to track it down :)

@skwp

The strange part, after I close the conque term, everything is back to normal.

@kien
Owner

Just a guess, so let me know if this changes anything. For autoload/ctrlp.vim:

@@ -1115,16 +1115,19 @@ fu! ctrlp#statusline()
        \ exists('s:marked') ? ' <'.s:dismrk().'>' : ' <->' : ''
    if s:status != {}
        let args = [focus, byfname, s:regexp, prv, item, nxt, marked]
-       let &l:stl = call(s:status['main'], args)
-   el
-       let item    = '%#CtrlPMode1# '.item.' %*'
-       let focus   = '%#CtrlPMode2# '.focus.' %*'
-       let byfname = '%#CtrlPMode1# '.byfname.' %*'
-       let regex   = s:regexp  ? '%#CtrlPMode2# regex %*' : ''
-       let slider  = ' <'.prv.'>={'.item.'}=<'.nxt.'>'
-       let dir     = ' %=%<%#CtrlPMode2# '.s:dyncwd.' %*'
-       let &l:stl  = focus.byfname.regex.slider.marked.dir
+       try
+           let &l:stl = call(s:status['main'], args)
+           retu
+       cat
+       endt
    en
+   let item    = '%#CtrlPMode1# '.item.' %*'
+   let focus   = '%#CtrlPMode2# '.focus.' %*'
+   let byfname = '%#CtrlPMode1# '.byfname.' %*'
+   let regex   = s:regexp  ? '%#CtrlPMode2# regex %*' : ''
+   let slider  = ' <'.prv.'>={'.item.'}=<'.nxt.'>'
+   let dir     = ' %=%<%#CtrlPMode2# '.s:dyncwd.' %*'
+   let &l:stl  = focus.byfname.regex.slider.marked.dir
 endf

 fu! s:dismrk()
@@ -1134,11 +1137,22 @@ endf
  fu! ctrlp#progress(enum, ...)
    if has('macunix') || has('mac') | sl 1m | en
-   let txt = a:0 ? '(press ctrl-c to abort)' : ''
-   let &l:stl = s:status != {} ? call(s:status['prog'], [a:enum])
-       \ : '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# '.s:dyncwd.' %*'
+   if s:status != {}
+       try
+           let &l:stl = call(s:status['prog'], [a:enum])
+           redraws | retu
+       cat
+       endt
+   en
+   cal s:progstl(a:enum, a:0)
    redraws
 endf
+
+fu! s:progstl(enum, txt)
+   let txt = a:txt ? '(press ctrl-c to abort)' : ''
+   let &l:stl =
+       \ '%#CtrlPStats# '.a:enum.' %* '.txt.'%=%<%#CtrlPMode2# '.s:dyncwd.' %*'
+endf
 " Paths {{{2
 fu! s:formatline(str)
    let cond = s:ispath && ( s:winw - 4 ) < s:strwidth(a:str)

If that doesn't work then try this and see if it makes any differences. Also for autoload/ctrlp.vim:

-   sil! exe 'noa keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
+   sil! exe 'keepa' ( s:mwbottom ? 'bo' : 'to' ) '1new ControlP'
-   try | noa bun!
-   cat | noa clo! | endt
+   try | bun!
+   cat | clo! | endt
@skwp

@kien thanks so much for taking the time to try to provide a fix. i'm having some trouble applying the patch. any chance you can just drop it in a branch and push it out? thanks!

@kien kien referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kien kien referenced this issue from a commit
Commit has since been removed from the repository and is no longer available.
@kien
Owner

Done, both are on the test branch.

@skwp

Thanks kien, seems neither nor both fix my problem. I'll get into more detailed debugging by myself..thanks for your help

@kien
Owner

Can you help me run one last test? Instead of opening ctrlp, run each of these in the same conditions that cause the error if you run :CtrlP app/models:

:vnew | lcd /absolute/path/to/app/models | redraw
:noa vnew | lcd /absolute/path/to/app/models | redraw
@skwp

Thanks so much for helping with this @kien. Running the first command (with the conque window open after running a conque rspec):

Error detected while processing function Powerline#Functions#fugitive#GetBranch..fugitive#statusline..<SNR>130_repo_head_ref:
line    1:
E484: Can't open file ./.git/HEAD
E684: list index out of range: 0                                                     [Git] ⮀ spec fast_spec/controllers/salesforce_shares_controller_spec.rb --color ->
E15: Invalid expression: readfile(self.dir('HEAD'))[0]     

The second command gives the same. I suspect you're trying to see if there's some autocommand getting in the way here? But I think it's actually something to do with the window system.

By the way, these errors appear only in the UI. In the ctrlp log I only see this error, which seems to happen any time I invoke ctrlp

Error detected while processing function <SNR>18_BMRemove:
line    9:
E329: No menu "ControlP (3)
@skwp

I removed the powerline plugin and things work just fine. So it must be some conflict in the powerline fugitive integration. Given the errors, my guess is that it's looking in the wrong path. Is there a chance that when we do "CtrlP some/path" that the current directory path is overwritten so that the fugitive integration craps out?

@kien
Owner

the current directory path is overwritten so that the fugitive integration craps out

Kind of, but also not exactly (check out :help :lcd). And as the small test with :vnew shows, this happens when you use :lcd and :redraw in the same window, you don't even need ctrlp.

Anyway, I think I'll close this as a wontfix because:

  • :redraw is much needed to properly display the prompt. Can't stop using it just to workaround this. The same goes for :lcd, it's needed to make sure no working directory is clobbered.
  • It's an edge case compatibility issue, specifically with skwp/vim-ruby-conque, and the error actually comes from fugitive (which uses a naked readfile()).

For the error in the GUI, I noticed it when working on preserving v:errmsg so it should already be fixed in 80bc9ce.

@kien kien closed this
@skwp

Thanks @kien . I agree it's not a ctrlp issue. I'll try to debug within fugitive/powerline and see if I can submit a pull request for those guys.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.