On 2014-06-07 15:16 +0100, Balazs Kezes wrote:
> OK, I've attached a patch which fixes the behavior for the vi mode and
> also fixes the left key bug for the emacs mode. Please test both
> modes!

Hi Nicholas!

I believe you missed this patch, can you reconsider?

Thanks!

-- 
Balazs
>From 49b46f56046bf562e7de084fd6f580e4841e0fa1 Mon Sep 17 00:00:00 2001
From: Balazs Kezes <rlblas...@gmail.com>
Date: Sat, 7 Jun 2014 15:05:38 +0100
Subject: [PATCH] Fix the selection behavior bugs

The two bugs:
1. In vi mode the selection doesn't include the last character if you moved the
cursor up or left.
2. In emacs mode the selection includes the last character if you moved the
cursor to the left.
---
 screen.c      | 23 ++++++++++++++++++-----
 tmux.h        |  1 +
 window-copy.c |  1 +
 3 files changed, 20 insertions(+), 5 deletions(-)

diff --git a/screen.c b/screen.c
index 7bfc015..d97e31b 100644
--- a/screen.c
+++ b/screen.c
@@ -277,6 +277,7 @@ int
 screen_check_selection(struct screen *s, u_int px, u_int py)
 {
 	struct screen_sel	*sel = &s->sel;
+	u_int			 xx;
 
 	if (!sel->flag)
 		return (0);
@@ -326,16 +327,24 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
 			if (py < sel->sy || py > sel->ey)
 				return (0);
 
-			if ((py == sel->sy && px < sel->sx)
-			    || (py == sel->ey && px > sel->ex))
+			if (py == sel->sy && px < sel->sx)
+				return 0;
+
+			if (py == sel->ey && px > sel->ex)
 				return (0);
 		} else if (sel->sy > sel->ey) {
 			/* starting line > ending line -- upward selection. */
 			if (py > sel->sy || py < sel->ey)
 				return (0);
 
-			if ((py == sel->sy && px >= sel->sx)
-			    || (py == sel->ey && px < sel->ex))
+			if (py == sel->ey && px < sel->ex)
+				return (0);
+
+			if (sel->mode_keys == MODEKEY_EMACS)
+				xx = sel->sx-1;
+			else
+				xx = sel->sx;
+			if (py == sel->sy && px > xx)
 				return (0);
 		} else {
 			/* starting line == ending line. */
@@ -344,7 +353,11 @@ screen_check_selection(struct screen *s, u_int px, u_int py)
 
 			if (sel->ex < sel->sx) {
 				/* cursor (ex) is on the left */
-				if (px > sel->sx || px < sel->ex)
+				if (sel->mode_keys == MODEKEY_EMACS)
+					xx = sel->sx-1;
+				else
+					xx = sel->sx;
+				if (px > xx || px < sel->ex)
 					return (0);
 			} else {
 				/* selection start (sx) is on the left */
diff --git a/tmux.h b/tmux.h
index 1f80f41..27db059 100644
--- a/tmux.h
+++ b/tmux.h
@@ -756,6 +756,7 @@ LIST_HEAD(joblist, job);
 struct screen_sel {
 	int		 flag;
 	int		 rectflag;
+	int		 mode_keys; /* vim or emacs mode? */
 
 	u_int		 sx;
 	u_int		 sy;
diff --git a/window-copy.c b/window-copy.c
index ac29e6d..79bfe7d 100644
--- a/window-copy.c
+++ b/window-copy.c
@@ -195,6 +195,7 @@ window_copy_init(struct window_pane *wp)
 		s->mode |= MODE_MOUSE_STANDARD;
 
 	keys = options_get_number(&wp->window->options, "mode-keys");
+	s->sel.mode_keys = keys;
 	if (keys == MODEKEY_EMACS)
 		mode_key_init(&data->mdata, &mode_key_tree_emacs_copy);
 	else
-- 
2.0.0.526.g5318336

------------------------------------------------------------------------------
_______________________________________________
tmux-users mailing list
tmux-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/tmux-users

Reply via email to