aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/mbyte.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/nvim/mbyte.c')
-rw-r--r--src/nvim/mbyte.c21
1 files changed, 16 insertions, 5 deletions
diff --git a/src/nvim/mbyte.c b/src/nvim/mbyte.c
index e4d2d35c1b..378a08131d 100644
--- a/src/nvim/mbyte.c
+++ b/src/nvim/mbyte.c
@@ -1182,6 +1182,11 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
return 1; // punctuation
}
+ // emoji
+ if (intable(emoji_all, ARRAY_SIZE(emoji_all), c)) {
+ return 3;
+ }
+
// binary search in table
while (top >= bot) {
mid = (bot + top) / 2;
@@ -1194,11 +1199,6 @@ int utf_class_tab(const int c, const uint64_t *const chartab)
}
}
- // emoji
- if (intable(emoji_all, ARRAY_SIZE(emoji_all), c)) {
- return 3;
- }
-
// most other characters are "word" characters
return 2;
}
@@ -2858,3 +2858,14 @@ void f_setcellwidths(typval_T *argvars, typval_T *rettv, FunPtr fptr)
xfree(cw_table_save);
redraw_all_later(NOT_VALID);
}
+
+void f_charclass(typval_T *argvars, typval_T *rettv, FunPtr fptr)
+{
+ if (argvars[0].v_type != VAR_STRING
+ || argvars[0].vval.v_string == NULL
+ || *argvars[0].vval.v_string == NUL) {
+ emsg(_(e_stringreq));
+ return;
+ }
+ rettv->vval.v_number = mb_get_class((const char_u *)argvars[0].vval.v_string);
+}