aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-03-14 09:13:17 -0400
committerJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-04-26 19:17:16 -0400
commit355dffdd769ffb12ad3e54528fb6910b08facb6c (patch)
treeefad2325636f7827038f4f8eadfe3b2ea7358cea
parent7d028f07657f1839819f81bade576591d2a778f9 (diff)
downloadrneovim-355dffdd769ffb12ad3e54528fb6910b08facb6c.tar.gz
rneovim-355dffdd769ffb12ad3e54528fb6910b08facb6c.tar.bz2
rneovim-355dffdd769ffb12ad3e54528fb6910b08facb6c.zip
vim-patch:8.0.1138: click in window toolbar starts Visual mode
Problem: Click in window toolbar starts Visual mode. Solution: Add the MOUSE_WINBAR flag. https://github.com/vim/vim/commit/eb163d73b11c10b461a2839530173a33d7915a33
-rw-r--r--src/nvim/mouse.c8
-rw-r--r--src/nvim/mouse.h1
-rw-r--r--src/nvim/normal.c9
3 files changed, 16 insertions, 2 deletions
diff --git a/src/nvim/mouse.c b/src/nvim/mouse.c
index 88a9cb2d5e..da585ca1e7 100644
--- a/src/nvim/mouse.c
+++ b/src/nvim/mouse.c
@@ -60,6 +60,7 @@ int jump_to_mouse(int flags,
{
static int on_status_line = 0; // #lines below bottom of window
static int on_sep_line = 0; // on separator right of window
+ static bool in_winbar = false;
static int prev_row = -1;
static int prev_col = -1;
static win_T *dragwin = NULL; // window being dragged
@@ -139,8 +140,10 @@ retnomove:
// A click in the window toolbar does not enter another window or
// change Visual highlighting.
winbar_click(wp, col);
- return IN_OTHER_WIN;
+ in_winbar = true;
+ return IN_OTHER_WIN | MOUSE_WINBAR;
}
+ in_winbar = false;
// winpos and height may change in win_enter()!
if (grid == DEFAULT_GRID_HANDLE && row >= wp->w_height) {
@@ -231,6 +234,9 @@ retnomove:
did_drag |= count;
}
return IN_SEP_LINE; // Cursor didn't move
+ } else if (in_winbar) {
+ // After a click on the window toolbar don't start Visual mode.
+ return IN_OTHER_WIN | MOUSE_WINBAR;
} else {
// keep_window_focus must be true
// before moving the cursor for a left click, stop Visual mode
diff --git a/src/nvim/mouse.h b/src/nvim/mouse.h
index 0149f7c7c0..6c5bc5dc0e 100644
--- a/src/nvim/mouse.h
+++ b/src/nvim/mouse.h
@@ -16,6 +16,7 @@
#define CURSOR_MOVED 0x100
#define MOUSE_FOLD_CLOSE 0x200 // clicked on '-' in fold column
#define MOUSE_FOLD_OPEN 0x400 // clicked on '+' in fold column
+#define MOUSE_WINBAR 0x800 // in window toolbar
// flags for jump_to_mouse()
#define MOUSE_FOCUS 0x01 // need to stay in this window
diff --git a/src/nvim/normal.c b/src/nvim/normal.c
index 58993426dd..ea8155f6b8 100644
--- a/src/nvim/normal.c
+++ b/src/nvim/normal.c
@@ -2559,7 +2559,14 @@ do_mouse (
* JUMP!
*/
jump_flags = jump_to_mouse(jump_flags,
- oap == NULL ? NULL : &(oap->inclusive), which_button);
+ oap == NULL ? NULL : &(oap->inclusive),
+ which_button);
+
+ // A click in the window toolbar has no side effects.
+ if (jump_flags & MOUSE_WINBAR) {
+ return false;
+ }
+
moved = (jump_flags & CURSOR_MOVED);
in_status_line = (jump_flags & IN_STATUS_LINE);
in_sep_line = (jump_flags & IN_SEP_LINE);