]> granicus.if.org Git - vim/commitdiff
patch 8.1.1165: no test for mouse clicks in the terminal tabpage line v8.1.1165
authorBram Moolenaar <Bram@vim.org>
Sat, 13 Apr 2019 12:53:16 +0000 (14:53 +0200)
committerBram Moolenaar <Bram@vim.org>
Sat, 13 Apr 2019 12:53:16 +0000 (14:53 +0200)
Problem:    No test for mouse clicks in the terminal tabpage line.
Solution:   Add a test. (Dominique Pelle, closes #4247).  Also init
            TabPageIdxs[], in case it's used before a redraw.

src/screen.c
src/testdir/test_termcodes.vim
src/version.c

index 46e3f629f5efe3472b0eea2d6aade5d2c5eb894b..1c21b7430f68f045fdb42aa6964c3aebd746c427 100644 (file)
@@ -8638,6 +8638,18 @@ check_for_delay(int check_msg_scroll)
     }
 }
 
+/*
+ * Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect.
+ */
+    static void
+clear_TabPageIdxs(void)
+{
+    int                scol;
+
+    for (scol = 0; scol < Columns; ++scol)
+       TabPageIdxs[scol] = 0;
+}
+
 /*
  * screen_valid -  allocate screen buffers if size changed
  *   If "doclear" is TRUE: clear screen if it has been resized.
@@ -8899,7 +8911,6 @@ give_up:
     must_redraw = CLEAR;       /* need to clear the screen later */
     if (doclear)
        screenclear2();
-
 #ifdef FEAT_GUI
     else if (gui.in_use
            && !gui.starting
@@ -8919,6 +8930,7 @@ give_up:
            msg_col = Columns - 1;      /* put cursor at last column */
     }
 #endif
+    clear_TabPageIdxs();
 
     entered = FALSE;
     --RedrawingDisabled;
@@ -10435,10 +10447,7 @@ draw_tabline(void)
        return;
 
 #if defined(FEAT_STL_OPT)
-
-    /* Init TabPageIdxs[] to zero: Clicking outside of tabs has no effect. */
-    for (scol = 0; scol < Columns; ++scol)
-       TabPageIdxs[scol] = 0;
+    clear_TabPageIdxs();
 
     /* Use the 'tabline' option if it's set. */
     if (*p_tal != NUL)
index 949fa94814ccf16317f44919a358f924ddb6986c..9a8fe155fc1a8cea23bc5c6807f4b585ce45f37c 100644 (file)
@@ -165,7 +165,8 @@ func Test_xterm_mouse_drag_statusline()
   let save_mouse = &mouse
   let save_term = &term
   let save_ttymouse = &ttymouse
-  set mouse=a term=xterm
+  let save_laststatus = &laststatus
+  set mouse=a term=xterm laststatus=2
 
   for ttymouse_val in ['xterm', 'sgr']
     exe 'set ttymouse=' . ttymouse_val
@@ -194,6 +195,53 @@ func Test_xterm_mouse_drag_statusline()
     call assert_equal(rowstatusline, winheight(0) + 1)
   endfor
 
+  let &mouse = save_mouse
+  let &term = save_term
+  let &ttymouse = save_ttymouse
+  let &laststatus = save_laststatus
+endfunc
+
+func Test_xterm_mouse_click_tab()
+  let save_mouse = &mouse
+  let save_term = &term
+  let save_ttymouse = &ttymouse
+  set mouse=a term=xterm
+  let row = 1
+
+  for ttymouse_val in ['xterm', 'sgr']
+    exe 'set ttymouse=' . ttymouse_val
+    e Xfoo
+    tabnew Xbar
+
+    let a = split(execute(':tabs'), "\n")
+    call assert_equal(['Tab page 1',
+        \              '    Xfoo',
+        \              'Tab page 2',
+        \              '>   Xbar'], a)
+
+    " Test clicking on tab names in the tabline at the top.
+    let col = 2
+    redraw!
+    call MouseLeftClick(row, col)
+    call MouseLeftRelease(row, col)
+    let a = split(execute(':tabs'), "\n")
+    call assert_equal(['Tab page 1',
+        \              '>   Xfoo',
+        \              'Tab page 2',
+        \              '    Xbar'], a)
+
+    let col = 9
+    call MouseLeftClick(row, col)
+    call MouseLeftRelease(row, col)
+    let a = split(execute(':tabs'), "\n")
+    call assert_equal(['Tab page 1',
+        \              '    Xfoo',
+        \              'Tab page 2',
+        \              '>   Xbar'], a)
+
+    %bwipe!
+  endfor
+
   let &mouse = save_mouse
   let &term = save_term
   let &ttymouse = save_ttymouse
index a53228dedab24d8cbbdcb937067b337bbfe5e6c3..881c67aa0d490c5378b8029a00154123d8501b71 100644 (file)
@@ -771,6 +771,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1165,
 /**/
     1164,
 /**/