1. Meikel Brandmeyer
  2. vimclojure
  3. Issues
Issue #97 resolved

PATCH] Ensure ranges are explicitly removed before :call

Sung Pae
created an issue

{{{ Bugfix for slow EvalBlock execution, as mentioned on the mailing list.

Does not include any changes to EvalBlock semantics!

cf. https://groups.google.com/forum/?fromgroups#!topic/vimclojure/FDfOGLAgSBk

Patch header:

Currently, <Plug>ClojureEvalBlock executes once for each line of the visual selection, resulting in a linear increase of execution time as the selection size grows.

This is due to a feature of :call that re-executes the given function for each line in a given range, unless the function explicitly handles ranges.

:[range]cal[l] {name}([arguments])
    When a range is given and the function doesn't handle it itself,
    the function is executed for each line in the range, with the
    cursor in the first column of that line. The cursor is left at
    the last line (possibly moved by the last function call). The
    arguments are re-evaluated for each line.

The mapping convention used to avoid this is to map the invocation as

:<C-U>call ...

which removes the :'<,'> range that is inserted on the command line when starting from visual mode. }}}

Comments (2)

  1. Meikel Brandmeyer repo owner
    • changed status to open
    • changed component to core
    • changed version to v2.3

    The correct way to fix this is to add the range option to the function called. Unfortunately we try to be too clever with the bindings and the function is only called indirectly. In this case <C-u> is hopefully ok.

  2. Log in to comment