mirror of
https://github.com/neovim/neovim.git
synced 2025-09-18 01:08:20 +00:00
Fixed ordering of signs to align vim and neovim behaviour
This commit is contained in:
@@ -5261,7 +5261,7 @@ static int sign_compare(const void *a1, const void *a2)
|
||||
const signlist_T *s1 = *(const signlist_T **)a1;
|
||||
const signlist_T *s2 = *(const signlist_T **)a2;
|
||||
|
||||
// Sort by line number and the by id
|
||||
// Sort by line number, priority and id
|
||||
|
||||
if (s1->lnum > s2->lnum) {
|
||||
return 1;
|
||||
@@ -5269,12 +5269,18 @@ static int sign_compare(const void *a1, const void *a2)
|
||||
if (s1->lnum < s2->lnum) {
|
||||
return -1;
|
||||
}
|
||||
if (s1->id > s2->id) {
|
||||
if (s1->priority > s2->priority) {
|
||||
return -1;
|
||||
}
|
||||
if (s1->priority < s2->priority) {
|
||||
return 1;
|
||||
}
|
||||
if (s1->id < s2->id) {
|
||||
if (s1->id > s2->id) {
|
||||
return -1;
|
||||
}
|
||||
if (s1->id < s2->id) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@@ -331,8 +331,7 @@ void buf_addsign(
|
||||
// Update an existing sign
|
||||
sign->typenr = typenr;
|
||||
return;
|
||||
} else if ((lnum == sign->lnum && id != sign->id)
|
||||
|| (id < 0 && lnum < sign->lnum)) {
|
||||
} else if (lnum < sign->lnum) {
|
||||
insert_sign_by_lnum_prio(buf, prev, id, groupname, prio, lnum, typenr);
|
||||
return;
|
||||
}
|
||||
@@ -407,23 +406,20 @@ int buf_getsigntype(buf_T *buf, linenr_T lnum, SignType type,
|
||||
&& sign_get_attr(sign->typenr, SIGN_NUMHL) != 0))) {
|
||||
matches[nr_matches] = sign;
|
||||
nr_matches++;
|
||||
|
||||
if (nr_matches == ARRAY_SIZE(matches)) {
|
||||
// signlist is sorted with most important (priority, id), thus we
|
||||
// may stop as soon as we have max_signs matches
|
||||
if (nr_matches == ARRAY_SIZE(matches) || nr_matches >= max_signs) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (nr_matches > 0) {
|
||||
if (nr_matches > max_signs) {
|
||||
idx += nr_matches - max_signs;
|
||||
}
|
||||
|
||||
if (idx >= nr_matches) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return matches[idx]->typenr;
|
||||
return matches[nr_matches - idx -1]->typenr;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user