To: "Robert Webb" <
[email protected]>
Cc:
[email protected]
Subject: patch 5.4n.6 (was: gv bug)
In-Reply-To: <
[email protected]>
Robert Webb wrote:
> Here's a bug with "gv".
>
> - select some characters near the end of a line in visual mode (eg with
> "vlllll").
> - Exit visual mode ("v").
> - Delete the last part of the line, including all the characters that were
> previously selected ("D").
> - Now re-select the area ("gv").
>
> The cursor goes to a character position past the end of the line. Also, you
> can't move left with "h".
I see the problem. Actually, "h" does work, but since the cursor is way past
the end of the line you have to hit it a few more times.
Strange that there was no check for the start and end of the Visual area to
be on a valid character. I'll add that now.
Patch 5.4n.6
Problem: "gv" could reselect a Visual that starts and/or ends past the end
of a line. (Robert Webb)
Solution: Check that the start and end of the Visual area are on a valid
character by calling adjust_cursor().
Files: src/normal.c
*** ../vim-5.4n/src/normal.c Sun Jul 4 20:36:01 1999
--- src/normal.c Tue Jul 6 12:58:32 1999
***************
*** 4927,4954 ****
beep_flush();
else
{
if (VIsual_active)
{
- tpos = VIsual;
- VIsual = curbuf->b_visual_start;
- curbuf->b_visual_start = tpos;
i = VIsual_mode;
VIsual_mode = curbuf->b_visual_mode;
curbuf->b_visual_mode = i;
! tpos = curwin->w_cursor;
! curwin->w_cursor = curbuf->b_visual_end;
! curbuf->b_visual_end = tpos;
}
else
{
- VIsual = curbuf->b_visual_start;
- curwin->w_cursor = curbuf->b_visual_end;
VIsual_mode = curbuf->b_visual_mode;
}
VIsual_active = TRUE;
VIsual_reselect = TRUE;
! check_cursor_lnum();
update_topline();
/*
* When called from normal "g" command: start Select mode when
--- 4927,4959 ----
beep_flush();
else
{
+ /* set w_cursor to the start of the Visual area, tpos to the end */
if (VIsual_active)
{
i = VIsual_mode;
VIsual_mode = curbuf->b_visual_mode;
curbuf->b_visual_mode = i;
! tpos = curbuf->b_visual_end;
! curbuf->b_visual_end = curwin->w_cursor;
! curwin->w_cursor = curbuf->b_visual_start;
! curbuf->b_visual_start = VIsual;
}
else
{
VIsual_mode = curbuf->b_visual_mode;
+ tpos = curbuf->b_visual_end;
+ curwin->w_cursor = curbuf->b_visual_start;
}
VIsual_active = TRUE;
VIsual_reselect = TRUE;
!
! /* Set Visual to the start and w_cursor to the end of the Visual
! * area. Make sure they are on an existing character. */
! adjust_cursor();
! VIsual = curwin->w_cursor;
! curwin->w_cursor = tpos;
! adjust_cursor();
update_topline();
/*
* When called from normal "g" command: start Select mode when
--
VOICE OVER: As the horrendous Black Beast lunged forward, escape for Arthur
and his knights seemed hopeless, when, suddenly ... the animator
suffered a fatal heart attack.
ANIMATOR: Aaaaagh!
VOICE OVER: The cartoon peril was no more ... The Quest for Holy Grail could
continue.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD
--/-/---- Bram Moolenaar ----
[email protected] ----
[email protected] ---\-\--
\ \ www.vim.org/iccf www.moolenaar.net www.vim.org / /