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

Prefer previously used choices #1

Open
p0deje opened this issue Feb 28, 2014 · 4 comments
Open

Prefer previously used choices #1

p0deje opened this issue Feb 28, 2014 · 4 comments

Comments

@p0deje
Copy link

p0deje commented Feb 28, 2014

First of all, thanks for the awesome plugin!

There is a single problem which still bothers me comparing to ST command palette. Here is an example of usage:

  1. I open CmdPalette and write "buf".
  2. The first result I receive is "CtrlPBufTag".
  3. I scroll up to "buffer" command and hit Enter two times to execute the command.

Now, the next time I repeat this, the resullt will be the same (i.e. "CtrlPBufTag" instead of "buffer" will be found first). In Sublime Text, however, it remembers the command I have chosen and makes it the first result for the subsequent searches.

Is it possible to implement something like this in CtrlP?

@fisadev
Copy link
Owner

fisadev commented Mar 5, 2014

That's true, it bothers me too.
As it is implemented, I couldn't define that behaviour in this plugin, because it's just a provider of data for CtrlP, which has the logic for filtering and choosing matches. But let me investigate on the CtrlP side, and if it can't be done then we could open an issue on that project.

@bsuh
Copy link

bsuh commented Oct 20, 2014

It seems that CtrlP doesn't reorder the data, only filters it. Here's a simple diff for prioritizing recently used commands for the current vim session.

diff --git a/autoload/ctrlp/cmdpalette.vim b/autoload/ctrlp/cmdpalette.vim
index 2826029..ee18218 100644
--- a/autoload/ctrlp/cmdpalette.vim
+++ b/autoload/ctrlp/cmdpalette.vim
@@ -91,6 +91,8 @@ func! ctrlp#cmdpalette#accept(mode, str)
   if g:ctrlp_cmdpalette_execute == 1
     call feedkeys("\<CR>", 'n')
   endif
+  call remove(s:cmdpalette_commands, index(s:cmdpalette_commands, a:str))
+  call insert(s:cmdpalette_commands, a:str)
 endfunc

It removes the command from the list and reinserts it in the beginning.

I think the actual enhancement should have a command history file, so ordering of commands can be preserved across sessions. I would work on it and make a pull request, but my vimscript-fu is weak right now.

@fisadev
Copy link
Owner

fisadev commented Oct 27, 2014

seems reasonable to me to do this simple change to remember used commands, will implement it, thanks for the idea and code!

As for having a file to preserve ordering across sessions, I'll do it later, not today, and probably not before pyconar 2014 :) (knee deep in conf related work, hehe).

@fisadev
Copy link
Owner

fisadev commented Oct 27, 2014

Done!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants