2015-04-26 18:17 GMT+03:00 Mark Volkmann <r.mark.volkmann@gmail.com>:
> When I do this I often see stray characters displayed in the current buffer.
> For example, I can press "j" several times to move down in the current
> buffer.
> It will work a few times and then start displaying "j" characters instead of
> moving down.
> After that point, if I press the esc key I will see "^[" displayed.
> The function I use to get my statusline string is called each time the
> cursor is moved.
> The problem goes away if I remove calls to system() in that function.
> Is this possibly related to the system() calls taking a while to return?
It is related to statusline function taking too much to run, not to
the system() function directly.
Problem is that each system() call is at two fork()s* with two
execve()s and each of this is not particularly fast. The whole thing
is much slower on Windows. And also one system() call is a number of
open() or stat() calls (to read shell configuration files) (cached) +
open() call for temporary file (2 times: one for writing, done by
shell, one for reading, done by vim) (because Vim does not use pipes)
(most likely cached) + loads of open()s for shared libraries for both
processes (shell and whatever command you run) (cached) + whatever
other initialization steps are done by shell or your script.
This is far worse if you happen to use `-i` in &shellcmdflag because
this way shell reads user configuration.
* Some shells are able to optimize this to one fork() (done by Vim,
not by shell), but execve() and other stuff is always there:
:echo system("python -c \"print($$); import os; print(os.getpid())\"")
" set shell=/bin/zsh shellcmdflag=-c: two identical numbers: no fork()
" set shell=/bin/bash: two different numbers
>
> This is how I configured my statusline:
>
> setlocal statusline=%!MyStatuslineFunction()
>
> --
> R. Mark Volkmann
> Object Computing, Inc.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups
> "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment