Fwd: exclusive vs. inclusive actions and selection

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

Fwd: exclusive vs. inclusive actions and selection

Benjamin Fritz
Forwarding to vim_dev from vim_use, seems to be a bug introduced since
7.2.284

John Little cannot duplicate the behavior on 7.2.284, but I see it on
7.2.320 on Windows gvim launched with -N -u NONE.

If it isn't clear, I had to :set selection=exclusive to see the
puzzling behavior. I assume he did this.


---------- Forwarded message ----------
From: Ben Fritz <[hidden email]>
Date: Jan 7, 12:14 pm
Subject: exclusive vs. inclusive actions and selection
To: vim_use


I'm a little puzzled over "exclusive" vs. "inclusive" actions and how
they interact with the 'selection' option.

Specifically, the 'e' and 'g_' commands seem inconsistent to me.

:help e says the cursor will be placed on the end of a word
(inclusive).

:help g_ says the cursor will be placed on the last nonblank character
in a line (also inclusive).

So, suppose I have a line with one word, like this:

anitdisestablishmentarianism

With 'selection' set to "inclusive", ^ve and ^vg_ do the same thing,
with a visual selection that looks like:

|anitdisestablishmentarianism|

With 'selection' set to "exclusive", ^ve gives:

|anitdisestablishmentarianism|

But ^vg_ gives:

|anitdisestablishmentarianis|m

This happens even with trailing whitespace on the line.

Why do two motions, both inclusive, that put the cursor in the same
place, create a different visual selection?

--
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

RE: exclusive vs. inclusive actions and selection

JohnBeckett
Ben Fritz wrote:
> I'm a little puzzled over "exclusive" vs. "inclusive" actions
> and how they interact with the 'selection' option.
>
> Specifically, the 'e' and 'g_' commands seem inconsistent to me.

I used gvim 7.2.323 and "gvim -N -u NONE" to verify Ben's
finding. Enter a line consisting of four characters, no spaces:
  abcd

Following is good:
Press 0 to put the cursor on 'a', then enter:
  :set selection=exclusive
  ye
  :echo @@
  yg_
  :echo @@

Result: "abcd" is yanked in both cases.
Same with ":set selection=inclusive".

Following is bad (unexpected by me):
  ve shows "abcd" as highlighted
  <Esc>0
  vg_ shows "abc" as highlighted (and "y" yanks "abc")

With ":set selection=inclusive", "abcd" is highlighted in both
cases (good).

John


--
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: exclusive vs. inclusive actions and selection

Bram Moolenaar
In reply to this post by Benjamin Fritz

Ben Fritz wrote:

> Forwarding to vim_dev from vim_use, seems to be a bug introduced since
> 7.2.284
>
> John Little cannot duplicate the behavior on 7.2.284, but I see it on
> 7.2.320 on Windows gvim launched with -N -u NONE.
>
> If it isn't clear, I had to :set selection=3Dexclusive to see the
> puzzling behavior. I assume he did this.

It's not clear to me what patch could have changed this.  This change
will fix it for "g_".  I wonder if there are other commands that have
the same problem.

*** ../vim-7.2.327/src/normal.c 2009-12-24 15:00:31.000000000 +0100
--- src/normal.c 2010-01-09 15:19:47.000000000 +0100
***************
*** 7873,7878 ****
--- 7873,7881 ----
     && vim_iswhite(ptr[curwin->w_cursor.col]))
  --curwin->w_cursor.col;
     curwin->w_set_curswant = TRUE;
+ #ifdef FEAT_VISUAL
+    adjust_for_sel(cap);
+ #endif
  }
  break;
 


--
From "know your smileys":
 <>:-) Bishop

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\        download, build and distribute -- http://www.A-A-P.org        ///
 \\\            help me help AIDS victims -- http://ICCF-Holland.org    ///

--
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
Reply | Threaded
Open this post in threaded view
|

Re: Fwd: exclusive vs. inclusive actions and selection

Lech Lorens
In reply to this post by Benjamin Fritz
On 09-Jan-2010 Ben Fritz <[hidden email]> wrote:
> Forwarding to vim_dev from vim_use, seems to be a bug introduced since
> 7.2.284
>
> John Little cannot duplicate the behavior on 7.2.284, but I see it on
> 7.2.320 on Windows gvim launched with -N -u NONE.

I've been able to reproduce it on 7.2.284. As a matter of fact I tried
a few older versions of Vim and managed to reproduce the problem as far
as in 7.0.0.

--
Cheers,
Lech

--
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php