aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLuuk van Baal <luukvbaal@gmail.com>2023-11-18 23:49:11 +0100
committerLuuk van Baal <luukvbaal@gmail.com>2023-11-22 12:43:59 +0100
commitc249058758af6919f718750b2f4acb96bafeb2dd (patch)
tree64002d073da4466869aea09e06b2d18734663d90 /src
parent34fa1e1ca4ddee0429f098a3ac885a716138fb6c (diff)
downloadrneovim-c249058758af6919f718750b2f4acb96bafeb2dd.tar.gz
rneovim-c249058758af6919f718750b2f4acb96bafeb2dd.tar.bz2
rneovim-c249058758af6919f718750b2f4acb96bafeb2dd.zip
feat(extmarks): add sign name to extmark "details" array
Problem: Unable to identify legacy signs when fetching extmarks with `nvim_buf_get_extmarks()`. Solution: Add "sign_name" to the extmark detail array. Add some misc. changes as follow-up to #25724
Diffstat (limited to 'src')
-rw-r--r--src/nvim/decoration.c4
-rw-r--r--src/nvim/sign.c15
2 files changed, 10 insertions, 9 deletions
diff --git a/src/nvim/decoration.c b/src/nvim/decoration.c
index 2ef689680d..0f4bbaaac7 100644
--- a/src/nvim/decoration.c
+++ b/src/nvim/decoration.c
@@ -1022,6 +1022,10 @@ void decor_to_dict_legacy(Dictionary *dict, DecorInline decor, bool hl_name)
PUT(*dict, "sign_text", CSTR_TO_OBJ(sh_sign.text.ptr));
}
+ if (sh_sign.sign_name) {
+ PUT(*dict, "sign_name", CSTR_TO_OBJ(sh_sign.sign_name));
+ }
+
// uncrustify:off
struct { char *name; const int val; } hls[] = {
diff --git a/src/nvim/sign.c b/src/nvim/sign.c
index 9a48b1b1a5..243e9e57cf 100644
--- a/src/nvim/sign.c
+++ b/src/nvim/sign.c
@@ -171,12 +171,12 @@ int sign_cmp(const void *p1, const void *p2)
? n : (sh2->sign_add_id - sh1->sign_add_id);
}
-/// Delete the specified signs
+/// Delete the specified sign(s)
///
/// @param buf buffer sign is stored in or NULL for all buffers
/// @param group sign group
/// @param id sign id
-/// @param atlnum sign at this line, -1 at any line
+/// @param atlnum single sign at this line, specified signs at any line when -1
static int buf_delete_signs(buf_T *buf, char *group, int id, linenr_T atlnum)
{
int64_t ns = group_get_ns(group);
@@ -187,7 +187,7 @@ static int buf_delete_signs(buf_T *buf, char *group, int id, linenr_T atlnum)
MarkTreeIter itr[1];
int row = atlnum > 0 ? atlnum - 1 : 0;
kvec_t(MTKey) signs = KV_INITIAL_VALUE;
- // Store and sort when removing a single sign at a specific line number.
+ // Store signs at a specific line number to remove one later.
if (atlnum > 0) {
if (!marktree_itr_get_overlap(buf->b_marktree, row, 0, itr)) {
return FAIL;
@@ -222,6 +222,7 @@ static int buf_delete_signs(buf_T *buf, char *group, int id, linenr_T atlnum)
}
}
+ // Sort to remove the highest priority sign at a specific line number.
if (kv_size(signs)) {
qsort((void *)&kv_A(signs, 0), kv_size(signs), sizeof(MTKey), sign_cmp);
extmark_del_id(buf, kv_A(signs, 0).ns, kv_A(signs, 0).id);
@@ -1198,11 +1199,7 @@ static int sign_define_from_dict(char *name, dict_T *dict)
numhl = tv_dict_get_string(dict, "numhl", false);
}
- if (sign_define_by_name(name, icon, text, linehl, texthl, culhl, numhl) == OK) {
- return 0;
- }
-
- return -1;
+ return sign_define_by_name(name, icon, text, linehl, texthl, culhl, numhl) - 1;
}
/// Define multiple signs using attributes from list 'l' and store the return
@@ -1563,7 +1560,7 @@ static int sign_unplace_from_dict(typval_T *group_tv, dict_T *dict)
}
}
- return sign_unplace(buf, id, group, 0) ? 0 : -1;
+ return sign_unplace(buf, id, group, 0) - 1;
}
/// "sign_unplace()" function