Asynchronous, non-blocking matching #542

Open
wants to merge 41 commits into
from

Conversation

Projects
None yet
2 participants

urandom commented Mar 8, 2014

Hello,

I've been playing around with making the matching phase of ctrlp asyncrhonous, since that was the biggest bottleneck when working on big projects.

I've reached the phase where things are actually looking good and I would like more eyes on the changes, and comments on whether this would be a good candidate for merging.

There are basically two sets of changes:

  1. The core of ctrlp is changed so that matching functions call a public #process function when they are done with the result, rather than returning it. This requires the current match plugin interface to be broken, but also allows plugins like cmatcher to execute their matching function in a separate/process thread, and then give the result to ctrlp for processing.
  2. A public function #forcecursorhold is introduced to force a cursorhold autocommand. This is in the core since only that has the necessary information to produce a cursorhold event without actually changing anything. Of course, matcher functions can also use the remote expression interface of vim for truly asynchronous matching.
  3. The match plugin interface now allows plugins to define whether they want ctrlp to always force an update, via the 'force_update' key. This is necessary when using the cursorhold event for asynchronous work.
  4. Finally, a matcher written in python is introduced, and used when vim has python support and lazy updating is active. The python matcher does the matching and sorting in a separate thread, and uses the cursorhold event to check if the thread has finished its work. The matcher is a drop-in replacement to the viml matcher and supports everything, including regexp matching using the vim regexp syntax

root and others added some commits Feb 28, 2014

root call a process function from the matcher instead of returning the lines 1c2fe90
@urandom urandom the process function needs to be called from other scripts 0b96bef
@urandom urandom python code for filtering in a thread 63d4f24
@urandom urandom define the script folder path 9ae4b5a
@urandom urandom add some missing python imports d57e516
@urandom urandom use the python matcher 7f21c56
@urandom urandom rename the python class 5cf1993
@urandom urandom add debug logging 4b2611e
@urandom urandom refactor the matcher 0cf4b0f
@urandom urandom do not reset the pymatcher variable fe565d0
@urandom urandom correctly set the pattern 9077887
@urandom urandom change the refresh feedkeys 97dc4f1
@urandom urandom force the update to go through e494a29
@urandom urandom start showing the items 2d79500
@urandom urandom fix case matching 6d0dcd6
@urandom urandom set the metadata on process 1362cc2
@urandom urandom create a cursorhold refresh function 2c609b1
@urandom urandom always show the matches in order 45fabcb
@urandom urandom do not process linues if the buffer doesn't exist 7d2f288
@urandom urandom clear the sequence if there is no pattern d778be6
@urandom urandom make the python interface be the same as the matcher plugin fe16d70
@urandom urandom allow matcher plugins to force the update 64fc444
@urandom urandom sort the matched items in python for more accuracy aff18e8
@urandom urandom python module for translating vim regex syntax to python 38a83ff
@urandom urandom turn on regex support c16f1b9
@urandom urandom fix processing of \\ 66f468c
@urandom urandom use bindeval to get the corrent type 334fa37
@urandom urandom correctly force a new cursorhold without changing the cursor 1a709b9
@urandom urandom fix the flag initialization 5028ff4
@urandom urandom use the correct string when creating a pattern b4a1e15
@urandom urandom do not sort if the pymatcher is used ebf2ab7
@urandom urandom give priority to mru files 2f349f9
@urandom urandom turn off debugging a98723a
@urandom urandom fix the tag filter 43a6278
@urandom urandom only process the last entry in the done queue
limit the number of matched items prior to sorting to trade accuracy
for performance
a77c733
@urandom urandom check for differences in the mode and path
that way changing from directory to file based searching will trigger
an update
2ab408f
@urandom urandom add more vim atoms 93aba0f
@urandom urandom use a noop func to force the cursorhold event
the previous method with moving the virtual cursor causes flickering
400494d
@urandom urandom always sort first by filename, for more accurate results af5bb89
@urandom urandom filter by recent files in the project first 7471f29
@urandom urandom show the mru files for the current project in the initial list first 09b3bca

d11wtq referenced this pull request in ctrlpvim/ctrlp.vim Aug 8, 2014

Closed

Asynchronous, non-blocking matching #9

d11wtq commented Aug 8, 2014

Moved to: ctrlpvim#9

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