@@ -165,6 +165,7 @@ static void f_get(typval_T *argvars, typval_T *rettv);
165165static void f_getbufinfo (typval_T * argvars , typval_T * rettv );
166166static void f_getbufline (typval_T * argvars , typval_T * rettv );
167167static void f_getbufvar (typval_T * argvars , typval_T * rettv );
168+ static void f_getchangelist (typval_T * argvars , typval_T * rettv );
168169static void f_getchar (typval_T * argvars , typval_T * rettv );
169170static void f_getcharmod (typval_T * argvars , typval_T * rettv );
170171static void f_getcharsearch (typval_T * argvars , typval_T * rettv );
@@ -607,6 +608,7 @@ static struct fst
607608 {"getbufinfo" , 0 , 1 , f_getbufinfo },
608609 {"getbufline" , 2 , 3 , f_getbufline },
609610 {"getbufvar" , 2 , 3 , f_getbufvar },
611+ {"getchangelist" , 1 , 1 , f_getchangelist },
610612 {"getchar" , 0 , 1 , f_getchar },
611613 {"getcharmod" , 0 , 0 , f_getcharmod },
612614 {"getcharsearch" , 0 , 0 , f_getcharsearch },
@@ -4346,6 +4348,58 @@ f_getbufvar(typval_T *argvars, typval_T *rettv)
43464348 -- emsg_off ;
43474349}
43484350
4351+ /*
4352+ * "getchangelist()" function
4353+ */
4354+ static void
4355+ f_getchangelist (typval_T * argvars , typval_T * rettv )
4356+ {
4357+ #ifdef FEAT_JUMPLIST
4358+ buf_T * buf ;
4359+ int i ;
4360+ list_T * l ;
4361+ dict_T * d ;
4362+ #endif
4363+
4364+ if (rettv_list_alloc (rettv ) != OK )
4365+ return ;
4366+
4367+ #ifdef FEAT_JUMPLIST
4368+ buf = find_buffer (& argvars [0 ]);
4369+ if (buf == NULL )
4370+ return ;
4371+
4372+ l = list_alloc ();
4373+ if (l == NULL )
4374+ return ;
4375+
4376+ if (list_append_list (rettv -> vval .v_list , l ) == FAIL )
4377+ return ;
4378+ /*
4379+ * The current window change list index tracks only the position in the
4380+ * current buffer change list. For other buffers, use the change list
4381+ * length as the current index.
4382+ */
4383+ list_append_number (rettv -> vval .v_list ,
4384+ (varnumber_T )((buf == curwin -> w_buffer )
4385+ ? curwin -> w_changelistidx : buf -> b_changelistlen ));
4386+
4387+ for (i = 0 ; i < buf -> b_changelistlen ; ++ i )
4388+ {
4389+ if (buf -> b_changelist [i ].lnum == 0 )
4390+ continue ;
4391+ if ((d = dict_alloc ()) == NULL )
4392+ return ;
4393+ if (list_append_dict (l , d ) == FAIL )
4394+ return ;
4395+ dict_add_nr_str (d , "lnum" , (long )buf -> b_changelist [i ].lnum , NULL );
4396+ dict_add_nr_str (d , "col" , (long )buf -> b_changelist [i ].col , NULL );
4397+ # ifdef FEAT_VIRTUALEDIT
4398+ dict_add_nr_str (d , "coladd" , (long )buf -> b_changelist [i ].coladd , NULL );
4399+ # endif
4400+ }
4401+ #endif
4402+ }
43494403/*
43504404 * "getchar()" function
43514405 */
0 commit comments