patch 8.2.1401: cannot jump to the last used tabpage

Problem:    Cannot jump to the last used tabpage.
Solution:   Add g<Tab> and tabpagnr('#'). (Yegappan Lakshmanan, closes #6661,
            neovim #11626)
diff --git a/src/window.c b/src/window.c
index 4b2ff4b..7d8122e 100644
--- a/src/window.c
+++ b/src/window.c
@@ -627,6 +627,11 @@
 			goto_tabpage(-(int)Prenum1);
 			break;
 
+		    case TAB:	    // CTRL-W g<Tab>: go to last used tab page
+			if (goto_tabpage_lastused() == FAIL)
+			    beep_flush();
+			break;
+
 		    default:
 			beep_flush();
 			break;
@@ -3809,6 +3814,9 @@
     unref_var_dict(tp->tp_vars);
 #endif
 
+    if (tp == lastused_tabpage)
+	lastused_tabpage = NULL;
+
     vim_free(tp->tp_localdir);
     vim_free(tp->tp_prevdir);
 
@@ -3883,6 +3891,8 @@
 	newtp->tp_topframe = topframe;
 	last_status(FALSE);
 
+	lastused_tabpage = tp;
+
 #if defined(FEAT_GUI)
 	// When 'guioptions' includes 'L' or 'R' may have to remove or add
 	// scrollbars.  Have to update them anyway.
@@ -4118,6 +4128,7 @@
     int		row;
     int		old_off = tp->tp_firstwin->w_winrow;
     win_T	*next_prevwin = tp->tp_prevwin;
+    tabpage_T	*last_tab = curtab;
 
     curtab = tp;
     firstwin = tp->tp_firstwin;
@@ -4160,6 +4171,8 @@
     if (curtab->tp_old_Columns != Columns && starting == 0)
 	shell_new_columns();	// update window widths
 
+    lastused_tabpage = last_tab;
+
 #if defined(FEAT_GUI)
     // When 'guioptions' includes 'L' or 'R' may have to remove or add
     // scrollbars.  Have to update them anyway.
@@ -4278,6 +4291,21 @@
 }
 
 /*
+ * Go to the last accessed tab page, if there is one.
+ * Return OK or FAIL
+ */
+    int
+goto_tabpage_lastused(void)
+{
+    if (valid_tabpage(lastused_tabpage))
+    {
+	goto_tabpage_tp(lastused_tabpage, TRUE, TRUE);
+	return OK;
+    }
+    return FAIL;
+}
+
+/*
  * Enter window "wp" in tab page "tp".
  * Also updates the GUI tab.
  */