inclusive or exclusive movement

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

inclusive or exclusive movement

dcuaron
Just wondering.  if you have the line
h12345h12345h
            ^
with your cursor at the carat and you do a dFh
you'd get
h12345h
      ^

now at this point if you did d; you think the deletion would again be exclusive
but instead it become inclusive.  so instead of being left with a single h you
have an empty line.  is this the correct behaviour or a bug?
Reply | Threaded
Open this post in threaded view
|

Re: inclusive or exclusive movement

Michael Naumann
On Thursday 15 September 2005 18:24, [hidden email] wrote:

> Just wondering.  if you have the line
> h12345h12345h
>             ^
> with your cursor at the carat and you do a dFh
> you'd get
> h12345h
>       ^
>
> now at this point if you did d; you think the deletion would again be exclusive
> but instead it become inclusive.  so instead of being left with a single h you
> have an empty line.  is this the correct behaviour or a bug?
>

In my opinion this is at least a desing-flaw.

A similar example is  $d0 compared to 0d$  on any line.
The two are not identical regarding inclusive/exclusive

Just my two cents, Michael

Reply | Threaded
Open this post in threaded view
|

Re: inclusive or exclusive movement

dcuaron
On Thu, 15 Sep 2005, Michael Naumann wrote:

> On Thursday 15 September 2005 18:24, [hidden email] wrote:
> > Just wondering.  if you have the line
> > h12345h12345h
> >             ^
> > with your cursor at the carat and you do a dFh
> > you'd get
> > h12345h
> >       ^
> >
> > now at this point if you did d; you think the deletion would again be exclusive
> > but instead it become inclusive.  so instead of being left with a single h you
> > have an empty line.  is this the correct behaviour or a bug?
> >
>
> In my opinion this is at least a desing-flaw.
>
> A similar example is  $d0 compared to 0d$  on any line.
> The two are not identical regarding inclusive/exclusive
>
> Just my two cents, Michael
>

Michael,
Your example at least makes sense to me.  0 is designated as an exclusive
movement and $ is designated at inclusive.  From my understanding 0d$ would
delete the whole line while $d0 would leave the last character.
Reply | Threaded
Open this post in threaded view
|

Re: inclusive or exclusive movement

Bram Moolenaar
In reply to this post by dcuaron

Nameless coward wrote:

> Just wondering.  if you have the line
> h12345h12345h
>             ^
> with your cursor at the carat and you do a dFh
> you'd get
> h12345h
>       ^
>
> now at this point if you did d; you think the deletion would again be
> exclusive but instead it become inclusive.  so instead of being left
> with a single h you have an empty line.  is this the correct behaviour
> or a bug?

That's a bug.  This patch will fix it:

--- normal.c 13 Sep 2005 21:10:34 -0000 1.42
+++ normal.c 15 Sep 2005 17:40:56 -0000
@@ -5834,10 +5834,6 @@
  t_cmd = FALSE;
 
     cap->oap->motion_type = MCHAR;
-    if (cap->arg == BACKWARD)
- cap->oap->inclusive = FALSE;
-    else
- cap->oap->inclusive = TRUE;
     if (IS_SPECIAL(cap->nchar) || searchc(cap, t_cmd) == FAIL)
  clearopbeep(cap->oap);
     else
--- search.c 14 Sep 2005 21:38:41 -0000 1.29
+++ search.c 15 Sep 2005 17:41:04 -0000
@@ -1440,6 +1440,11 @@
  /* For multi-byte re-use last bytes[] and bytelen. */
     }
 
+    if (dir == BACKWARD)
+ cap->oap->inclusive = FALSE;
+    else
+ cap->oap->inclusive = TRUE;
+
     p = ml_get_curline();
     col = curwin->w_cursor.col;
     len = (int)STRLEN(p);

--
GALAHAD:   Camelot ...
LAUNCELOT: Camelot ...
GAWAIN:    It's only a model.
                 "Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///