Christian Brabandt wrote:

> I noticed a strange behaviour today when using the d command.
> I was deleting several lines with a motion that selected the last non
> blank on a line. Surprisingly, this deleted the whole line. After
> searching the help, I found it explained by this paragraph in the help:
> 
>     An exception for the d{motion} command: If the motion is not
>     linewise, the start and end of the motion are not in the same line,
>     and there are only blanks before the start and after the end of the
>     motion, the delete becomes linewise.  This means that the delete
>     also removes the line of blanks that you might expect to remain.
> 
> So I tried the suggestion, made at :h o_v
> 
>     When used after an operator, before the motion command: Force
>     the operator to work characterwise, also when the motion is
>     linewise.  If the motion was linewise, it will become
>     |exclusive|.
>     If the motion already was characterwise, toggle
>     inclusive/exclusive.  This can be used to make an exclusive
>     motion inclusive and an inclusive motion exclusive.
> 
> But surprisingly did not work. So I propose the following fix:
> 
> diff --git a/src/ops.c b/src/ops.c
> --- a/src/ops.c
> +++ b/src/ops.c
> @@ -1648,6 +1648,7 @@
>             && !oap->block_mode
>  #endif
>             && oap->line_count > 1
> +           && !oap->motion_force
>             && oap->op_type == OP_DELETE)
>      {
>         ptr = ml_get(oap->end.lnum) + oap->end.col;

Yes, this makes sense.  Thanks for the patch.

Would there be other places where motion_force needs to be checked?

-- 
MONK: ... and the Lord spake, saying, "First shalt thou take out the Holy Pin,
      then shalt thou count to three, no more, no less.  Three shalt be the
      number thou shalt count, and the number of the counting shalt be three.
      Four shalt thou not count, neither count thou two, excepting that thou
      then proceed to three.  Five is right out.  Once the number three, being
      the third number, be reached, then lobbest thou thy Holy Hand Grenade of
      Antioch towards thou foe, who being naughty in my sight, shall snuff it.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\  an exciting new programming language -- http://www.Zimbu.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

-- 
You received this message from the "vim_dev" 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

Raspunde prin e-mail lui