Mercurial > vim
comparison src/evalwindow.c @ 29994:86eb4aba16c3 v9.0.0335
patch 9.0.0335: checks for Dictionary argument often give a vague error
Commit: https://github.com/vim/vim/commit/04c4c5746e15884768d2cb41370c3276a196cd4c
Author: Yegappan Lakshmanan <yegappan@yahoo.com>
Date: Tue Aug 30 19:48:24 2022 +0100
patch 9.0.0335: checks for Dictionary argument often give a vague error
Problem: Checks for Dictionary argument often give a vague error message.
Solution: Give a useful error message. (Yegappan Lakshmanan, closes https://github.com/vim/vim/issues/11009)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Tue, 30 Aug 2022 21:00:05 +0200 |
parents | 827d9f2b7a71 |
children | 6c1a9d7a931f |
comparison
equal
deleted
inserted
replaced
29993:8dd1900432a0 | 29994:86eb4aba16c3 |
---|---|
1007 if (argvars[2].v_type != VAR_UNKNOWN) | 1007 if (argvars[2].v_type != VAR_UNKNOWN) |
1008 { | 1008 { |
1009 dict_T *d; | 1009 dict_T *d; |
1010 dictitem_T *di; | 1010 dictitem_T *di; |
1011 | 1011 |
1012 if (argvars[2].v_type != VAR_DICT || argvars[2].vval.v_dict == NULL) | 1012 if (check_for_nonnull_dict_arg(argvars, 2) == FAIL) |
1013 { | |
1014 emsg(_(e_invalid_argument)); | |
1015 return; | 1013 return; |
1016 } | |
1017 | 1014 |
1018 d = argvars[2].vval.v_dict; | 1015 d = argvars[2].vval.v_dict; |
1019 if (dict_get_bool(d, "vertical", FALSE)) | 1016 if (dict_get_bool(d, "vertical", FALSE)) |
1020 flags |= WSP_VERT; | 1017 flags |= WSP_VERT; |
1021 if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL) | 1018 if ((di = dict_find(d, (char_u *)"rightbelow", -1)) != NULL) |
1225 void | 1222 void |
1226 f_winrestview(typval_T *argvars, typval_T *rettv UNUSED) | 1223 f_winrestview(typval_T *argvars, typval_T *rettv UNUSED) |
1227 { | 1224 { |
1228 dict_T *dict; | 1225 dict_T *dict; |
1229 | 1226 |
1230 if (in_vim9script() && check_for_dict_arg(argvars, 0) == FAIL) | 1227 if (check_for_nonnull_dict_arg(argvars, 0) == FAIL) |
1231 return; | 1228 return; |
1232 | 1229 |
1233 if (argvars[0].v_type != VAR_DICT | 1230 dict = argvars[0].vval.v_dict; |
1234 || (dict = argvars[0].vval.v_dict) == NULL) | 1231 if (dict_has_key(dict, "lnum")) |
1235 emsg(_(e_invalid_argument)); | 1232 curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, "lnum"); |
1236 else | 1233 if (dict_has_key(dict, "col")) |
1237 { | 1234 curwin->w_cursor.col = (colnr_T)dict_get_number(dict, "col"); |
1238 if (dict_has_key(dict, "lnum")) | 1235 if (dict_has_key(dict, "coladd")) |
1239 curwin->w_cursor.lnum = (linenr_T)dict_get_number(dict, "lnum"); | 1236 curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, "coladd"); |
1240 if (dict_has_key(dict, "col")) | 1237 if (dict_has_key(dict, "curswant")) |
1241 curwin->w_cursor.col = (colnr_T)dict_get_number(dict, "col"); | 1238 { |
1242 if (dict_has_key(dict, "coladd")) | 1239 curwin->w_curswant = (colnr_T)dict_get_number(dict, "curswant"); |
1243 curwin->w_cursor.coladd = (colnr_T)dict_get_number(dict, "coladd"); | 1240 curwin->w_set_curswant = FALSE; |
1244 if (dict_has_key(dict, "curswant")) | 1241 } |
1245 { | 1242 |
1246 curwin->w_curswant = (colnr_T)dict_get_number(dict, "curswant"); | 1243 if (dict_has_key(dict, "topline")) |
1247 curwin->w_set_curswant = FALSE; | 1244 set_topline(curwin, (linenr_T)dict_get_number(dict, "topline")); |
1248 } | |
1249 | |
1250 if (dict_has_key(dict, "topline")) | |
1251 set_topline(curwin, (linenr_T)dict_get_number(dict, "topline")); | |
1252 #ifdef FEAT_DIFF | 1245 #ifdef FEAT_DIFF |
1253 if (dict_has_key(dict, "topfill")) | 1246 if (dict_has_key(dict, "topfill")) |
1254 curwin->w_topfill = (int)dict_get_number(dict, "topfill"); | 1247 curwin->w_topfill = (int)dict_get_number(dict, "topfill"); |
1255 #endif | 1248 #endif |
1256 if (dict_has_key(dict, "leftcol")) | 1249 if (dict_has_key(dict, "leftcol")) |
1257 curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol"); | 1250 curwin->w_leftcol = (colnr_T)dict_get_number(dict, "leftcol"); |
1258 if (dict_has_key(dict, "skipcol")) | 1251 if (dict_has_key(dict, "skipcol")) |
1259 curwin->w_skipcol = (colnr_T)dict_get_number(dict, "skipcol"); | 1252 curwin->w_skipcol = (colnr_T)dict_get_number(dict, "skipcol"); |
1260 | 1253 |
1261 check_cursor(); | 1254 check_cursor(); |
1262 win_new_height(curwin, curwin->w_height); | 1255 win_new_height(curwin, curwin->w_height); |
1263 win_new_width(curwin, curwin->w_width); | 1256 win_new_width(curwin, curwin->w_width); |
1264 changed_window_setting(); | 1257 changed_window_setting(); |
1265 | 1258 |
1266 if (curwin->w_topline <= 0) | 1259 if (curwin->w_topline <= 0) |
1267 curwin->w_topline = 1; | 1260 curwin->w_topline = 1; |
1268 if (curwin->w_topline > curbuf->b_ml.ml_line_count) | 1261 if (curwin->w_topline > curbuf->b_ml.ml_line_count) |
1269 curwin->w_topline = curbuf->b_ml.ml_line_count; | 1262 curwin->w_topline = curbuf->b_ml.ml_line_count; |
1270 #ifdef FEAT_DIFF | 1263 #ifdef FEAT_DIFF |
1271 check_topfill(curwin, TRUE); | 1264 check_topfill(curwin, TRUE); |
1272 #endif | 1265 #endif |
1273 } | |
1274 } | 1266 } |
1275 | 1267 |
1276 /* | 1268 /* |
1277 * "winsaveview()" function | 1269 * "winsaveview()" function |
1278 */ | 1270 */ |