aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/syntax.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/syntax.c')
-rw-r--r--src/nvim/syntax.c46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/nvim/syntax.c b/src/nvim/syntax.c
index c3bc009f6a..e2476f9b0b 100644
--- a/src/nvim/syntax.c
+++ b/src/nvim/syntax.c
@@ -2133,9 +2133,11 @@ syn_current_attr (
/* nextgroup ends at end of line, unless "skipnl" or "skipempty" present */
if (current_next_list != NULL
- && syn_getcurline()[current_col + 1] == NUL
- && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY)))
+ && (line = syn_getcurline())[current_col] != NUL
+ && line[current_col + 1] == NUL
+ && !(current_next_flags & (HL_SKIPNL | HL_SKIPEMPTY))) {
current_next_list = NULL;
+ }
if (!GA_EMPTY(&zero_width_next_ga))
ga_clear(&zero_width_next_ga);
@@ -7756,14 +7758,28 @@ static void highlight_list_two(int cnt, int attr)
}
-/*
- * Function given to ExpandGeneric() to obtain the list of group names.
- * Also used for synIDattr() function.
- */
-const char *get_highlight_name(expand_T *const xp, const int idx)
+/// Function given to ExpandGeneric() to obtain the list of group names.
+const char *get_highlight_name(expand_T *const xp, int idx)
+ FUNC_ATTR_WARN_UNUSED_RESULT
+{
+ return get_highlight_name_ext(xp, idx, true);
+}
+
+
+/// Obtain a highlight group name.
+/// When "skip_cleared" is TRUE don't return a cleared entry.
+const char *get_highlight_name_ext(expand_T *xp, int idx, int skip_cleared)
FUNC_ATTR_WARN_UNUSED_RESULT
{
- // TODO(justinmk): 'xp' is unused
+ if (idx < 0) {
+ return NULL;
+ }
+
+ // Items are never removed from the table, skip the ones that were cleared.
+ if (skip_cleared && idx < highlight_ga.ga_len && HL_TABLE()[idx].sg_cleared) {
+ return "";
+ }
+
if (idx == highlight_ga.ga_len && include_none != 0) {
return "none";
} else if (idx == highlight_ga.ga_len + include_none
@@ -7775,20 +7791,10 @@ const char *get_highlight_name(expand_T *const xp, const int idx)
} else if (idx == highlight_ga.ga_len + include_none + include_default + 1
&& include_link != 0) {
return "clear";
- } else if (idx < 0) {
- return NULL;
- }
-
- // Items are never removed from the table, skip the ones that were cleared.
- int current_idx = idx;
- while (current_idx < highlight_ga.ga_len
- && HL_TABLE()[current_idx].sg_cleared) {
- current_idx++;
- }
- if (current_idx >= highlight_ga.ga_len) {
+ } else if (idx >= highlight_ga.ga_len) {
return NULL;
}
- return (const char *)HL_TABLE()[current_idx].sg_name;
+ return (const char *)HL_TABLE()[idx].sg_name;
}
color_name_table_T color_name_table[] = {