changeset 25435:6ad76124ddda v8.2.3254

patch 8.2.3254: win_gettype() does not recognize a quickfix window Commit: https://github.com/vim/vim/commit/28d8421bfb3327d7a5e81369977e8fc108b0229e Author: Yegappan Lakshmanan <yegappan@yahoo.com> Date: Sat Jul 31 12:43:23 2021 +0200 patch 8.2.3254: win_gettype() does not recognize a quickfix window Problem: win_gettype() does not recognize a quickfix window. Solution: Add "quickfix" and "loclist". (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/8676)
author Bram Moolenaar <Bram@vim.org>
date Sat, 31 Jul 2021 12:45:05 +0200
parents b76d67278a14
children 1c4eb97d71a1
files runtime/doc/eval.txt src/evalwindow.c src/misc2.c src/testdir/test_quickfix.vim src/version.c
diffstat 5 files changed, 32 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/runtime/doc/eval.txt
+++ b/runtime/doc/eval.txt
@@ -11661,10 +11661,12 @@ win_gettype([{nr}])					*win_gettype()*
 		Return the type of the window:
 			"autocmd"	autocommand window. Temporary window
 					used to execute autocommands.
+			"command"	command-line window |cmdwin|
+			(empty)		normal window
+			"loclist"	|location-list-window|
 			"popup"		popup window |popup|
 			"preview"	preview window |preview-window|
-			"command"	command-line window |cmdwin|
-			(empty)		normal window
+			"quickfix"	|quickfix-window|
 			"unknown"	window {nr} not found
 
 		When {nr} is omitted return the type of the current window.
--- a/src/evalwindow.c
+++ b/src/evalwindow.c
@@ -953,6 +953,12 @@ f_win_gettype(typval_T *argvars, typval_
     else if (wp == curwin && cmdwin_type != 0)
 	rettv->vval.v_string = vim_strsave((char_u *)"command");
 #endif
+#ifdef FEAT_QUICKFIX
+    else if (bt_quickfix(wp->w_buffer))
+	rettv->vval.v_string = vim_strsave((char_u *)
+		(wp->w_llist_ref != NULL ? "loclist" : "quickfix"));
+#endif
+
 }
 
 /*
--- a/src/misc2.c
+++ b/src/misc2.c
@@ -1574,10 +1574,10 @@ ga_concat_len(garray_T *gap, char_u *s, 
 {
     if (s == NULL || *s == NUL)
 	return;
-    if (ga_grow(gap, len) == OK)
+    if (ga_grow(gap, (int)len) == OK)
     {
-	mch_memmove((char *)gap->ga_data + gap->ga_len, s, (size_t)len);
-	gap->ga_len += len;
+	mch_memmove((char *)gap->ga_data + gap->ga_len, s, len);
+	gap->ga_len += (int)len;
     }
 }
 
--- a/src/testdir/test_quickfix.vim
+++ b/src/testdir/test_quickfix.vim
@@ -5587,4 +5587,21 @@ func Test_locationlist_open_in_newtab()
   %bwipe!
 endfunc
 
+" Test for win_gettype() in quickfix and location list windows
+func Test_win_gettype()
+  copen
+  call assert_equal("quickfix", win_gettype())
+  let wid = win_getid()
+  wincmd p
+  call assert_equal("quickfix", win_gettype(wid))
+  cclose
+  lexpr ''
+  lopen
+  call assert_equal("loclist", win_gettype())
+  let wid = win_getid()
+  wincmd p
+  call assert_equal("loclist", win_gettype(wid))
+  lclose
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
--- a/src/version.c
+++ b/src/version.c
@@ -756,6 +756,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    3254,
+/**/
     3253,
 /**/
     3252,