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

Slow with many separators in large files #250

Open
infokiller opened this issue May 6, 2020 · 1 comment
Open

Slow with many separators in large files #250

infokiller opened this issue May 6, 2020 · 1 comment

Comments

@infokiller
Copy link
Contributor

I use the following setting:

" Add 'iB'/'aB'/'IB'/'AB' text objects for selecting between any separator,
" bracket, quote, or tag.
autocmd User targets#mappings#user call targets#mappings#extend({
    \ 'B': {
    \     'separator': [{'d':','}, {'d':'.'}, {'d':';'}, {'d':':'}, {'d':'+'}, {'d':'-'},
    \                   {'d':'='}, {'d':'~'}, {'d':'_'}, {'d':'*'}, {'d':'#'}, {'d':'/'},
    \                   {'d':'\'}, {'d':'|'}, {'d':'&'}, {'d':'$'}],
    \     'pair':      [{'o':'(', 'c':')'}, {'o':'[', 'c':']'}, {'o':'{', 'c':'}'}, {'o':'<', 'c':'>'}],
    \     'quote':     [{'d':"'"}, {'d':'"'}, {'d':'`'}],
    \     'tag':       [{}],
    \     },
\ })

It works fast in small files, but there's a large delay in large files (a few thousand lines), even if the separators are trivial to figure out, for example using diB in "tes|t" (where | is the cursor).

@wellle
Copy link
Owner

wellle commented May 26, 2020

Hey, thanks for opening this issue! The problem is that currently targets.vim checks each of the possible targets (,, ., ; and so on) and then selects the one closest to the cursor. So if some of those targets don't exist it basically has to scan the full file (possibly multiple times) before picking the best one. We need to make some changes to improve this. For example we could first check only the current line and return the best one if any is found. Otherwise check only visible lines and so on. I think this is a good idea but I can't promise you any improvements on this soon as I'm currently busy with other things. ✌️

(in case you care, I just opened a big PR adjust/rmq#88, next is to finish work on wellle/context.vim#10 (possibly other context.vim issues too), then finish #240 and then maybe something else like this 😉)

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

No branches or pull requests

2 participants