@@ -908,13 +908,13 @@ get_map_mode(char_u **cmdp, int forceit)
908908}
909909
910910/*
911- * Clear all mappings or abbreviations.
912- * ' abbr' should be FALSE for mappings, TRUE for abbreviations.
911+ * Clear all mappings (":mapclear") or abbreviations (":abclear") .
912+ * " abbr" should be FALSE for mappings, TRUE for abbreviations.
913913 */
914914 static void
915915map_clear (
916916 char_u * cmdp ,
917- char_u * arg UNUSED ,
917+ char_u * arg ,
918918 int forceit ,
919919 int abbr )
920920{
@@ -929,14 +929,14 @@ map_clear(
929929 }
930930
931931 mode = get_map_mode (& cmdp , forceit );
932- map_clear_int (curbuf , mode , local , abbr );
932+ map_clear_mode (curbuf , mode , local , abbr );
933933}
934934
935935/*
936936 * Clear all mappings in "mode".
937937 */
938938 void
939- map_clear_int (
939+ map_clear_mode (
940940 buf_T * buf , // buffer for local mappings
941941 int mode , // mode in which to delete
942942 int local , // TRUE for buffer-local mappings
@@ -2272,6 +2272,40 @@ check_map(
22722272 return NULL ;
22732273}
22742274
2275+ /*
2276+ * "hasmapto()" function
2277+ */
2278+ void
2279+ f_hasmapto (typval_T * argvars , typval_T * rettv )
2280+ {
2281+ char_u * name ;
2282+ char_u * mode ;
2283+ char_u buf [NUMBUFLEN ];
2284+ int abbr = FALSE;
2285+
2286+ if (in_vim9script ()
2287+ && (check_for_string_arg (argvars , 0 ) == FAIL
2288+ || check_for_opt_string_arg (argvars , 1 ) == FAIL
2289+ || (argvars [1 ].v_type != VAR_UNKNOWN
2290+ && check_for_opt_bool_arg (argvars , 2 ) == FAIL )))
2291+ return ;
2292+
2293+ name = tv_get_string (& argvars [0 ]);
2294+ if (argvars [1 ].v_type == VAR_UNKNOWN )
2295+ mode = (char_u * )"nvo" ;
2296+ else
2297+ {
2298+ mode = tv_get_string_buf (& argvars [1 ], buf );
2299+ if (argvars [2 ].v_type != VAR_UNKNOWN )
2300+ abbr = (int )tv_get_bool (& argvars [2 ]);
2301+ }
2302+
2303+ if (map_to_exists (name , mode , abbr ))
2304+ rettv -> vval .v_number = TRUE;
2305+ else
2306+ rettv -> vval .v_number = FALSE;
2307+ }
2308+
22752309/*
22762310 * Fill in the empty dictionary with items as defined by maparg builtin.
22772311 */
0 commit comments