aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/nvim/eval/typval.c10
-rw-r--r--src/nvim/tag.c33
-rw-r--r--src/nvim/window.c1
3 files changed, 22 insertions, 22 deletions
diff --git a/src/nvim/eval/typval.c b/src/nvim/eval/typval.c
index 47c3551a56..25b2a20bac 100644
--- a/src/nvim/eval/typval.c
+++ b/src/nvim/eval/typval.c
@@ -2471,11 +2471,13 @@ void tv_dict_extend(dict_T *const d1, dict_T *const d2, const char *const action
}
if (di1 == NULL) {
if (*action == 'm') {
- // cheap way to move a dict item from "d2" to "d1"
+ // Cheap way to move a dict item from "d2" to "d1".
+ // If dict_add() fails then "d2" won't be empty.
dictitem_T *const new_di = di2;
- tv_dict_add(d1, new_di);
- hash_remove(&d2->dv_hashtab, hi2);
- tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL);
+ if (tv_dict_add(d1, new_di) == OK) {
+ hash_remove(&d2->dv_hashtab, hi2);
+ tv_dict_watcher_notify(d1, (const char *)new_di->di_key, &new_di->di_tv, NULL);
+ }
} else {
dictitem_T *const new_di = tv_dict_item_copy(di2);
if (tv_dict_add(d1, new_di) == FAIL) {
diff --git a/src/nvim/tag.c b/src/nvim/tag.c
index 8be343b055..7e4677e502 100644
--- a/src/nvim/tag.c
+++ b/src/nvim/tag.c
@@ -1475,7 +1475,7 @@ static bool findtags_in_help_init(findtags_state_T *st)
{
int i;
- // Keep 'en' as the language if the file extension is '.txt'
+ // Keep "en" as the language if the file extension is ".txt"
if (st->is_txt) {
STRCPY(st->help_lang, "en");
} else {
@@ -1724,6 +1724,14 @@ static bool findtags_start_state_handler(findtags_state_T *st, bool *sortic,
}
/// Parse a tag line read from a tags file.
+/// Also compares the tag name in "tagpp->tagname" with a search pattern in
+/// "st->orgpat->head" as a quick check if the tag may match.
+/// Returns:
+/// - TAG_MATCH_SUCCESS if the tag may match
+/// - TAG_MATCH_FAIL if the tag doesn't match
+/// - TAG_MATCH_NEXT to look for the next matching tag (used in a binary search)
+/// - TAG_MATCH_STOP if all the tags are processed without a match.
+/// Uses the values in "margs" for doing the comparison.
static tagmatch_status_T findtags_parse_line(findtags_state_T *st, tagptrs_T *tagpp,
findtags_match_args_T *margs,
tagsearch_info_T *sinfo_p)
@@ -1875,13 +1883,10 @@ static void findtags_matchargs_init(findtags_match_args_T *margs, int flags)
}
/// Compares the tag name in "tagpp->tagname" with a search pattern in
-/// "st->orgpat.head".
-/// Returns TAG_MATCH_SUCCESS if the tag matches, TAG_MATCH_FAIL if the tag
-/// doesn't match, TAG_MATCH_NEXT to look for the next matching tag (used in a
-/// binary search) and TAG_MATCH_STOP if all the tags are processed without a
-/// match. Uses the values in "margs" for doing the comparison.
-static tagmatch_status_T findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp,
- findtags_match_args_T *margs)
+/// "st->orgpat->pat".
+/// Returns true if the tag matches, false if the tag doesn't match.
+/// Uses the values in "margs" for doing the comparison.
+static bool findtags_match_tag(findtags_state_T *st, tagptrs_T *tagpp, findtags_match_args_T *margs)
{
bool match = false;
@@ -1925,7 +1930,7 @@ static tagmatch_status_T findtags_match_tag(findtags_state_T *st, tagptrs_T *tag
margs->match_re = true;
}
- return match ? TAG_MATCH_SUCCESS : TAG_MATCH_FAIL;
+ return match;
}
/// Convert the encoding of a line read from a tags file in "st->lbuf".
@@ -2182,16 +2187,8 @@ line_read_in:
return;
}
- retval = (int)findtags_match_tag(st, &tagp, margs);
- if (retval == TAG_MATCH_NEXT) {
- continue;
- }
- if (retval == TAG_MATCH_STOP) {
- break;
- }
-
// If a match is found, add it to ht_match[] and ga_match[].
- if (retval == TAG_MATCH_SUCCESS) {
+ if (findtags_match_tag(st, &tagp, margs)) {
findtags_add_match(st, &tagp, margs, buf_ffname, &hash);
}
} // forever
diff --git a/src/nvim/window.c b/src/nvim/window.c
index beb96aaa03..aacf30712a 100644
--- a/src/nvim/window.c
+++ b/src/nvim/window.c
@@ -5390,6 +5390,7 @@ static int check_window_scroll_resize(int *size_count, win_T **first_scroll_win,
// tv_list_set_item(winlist, listidx++, &tv);
tv_list_append_owned_tv(winlist, tv);
} else if (size_count != NULL) {
+ assert(first_size_win != NULL && first_scroll_win != NULL);
(*size_count)++;
if (*first_size_win == NULL) {
*first_size_win = wp;