revert: "feat(extmarks): subpriorities (relative to declaration order) (#27131)" (#28585)

This reverts commit 15e77a56b7.

Subpriorities were added in https://github.com/neovim/neovim/pull/27131
as a mechanism for enforcing query order when using iter_matches in the
Tree-sitter highlighter. However, iter_matches proved to have too many
complications to use in the highlighter so we eventually reverted back
to using iter_captures (https://github.com/neovim/neovim/pull/27901).
Thus, subpriorities are no longer needed and can be removed.
This commit is contained in:
Gregory Anders 2024-05-01 08:08:22 -05:00 committed by GitHub
parent b5583acc48
commit 0b8a72b739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 10 additions and 75 deletions

View File

@ -253,7 +253,6 @@ error('Cannot require a meta file')
--- @field undo_restore? boolean --- @field undo_restore? boolean
--- @field url? string --- @field url? string
--- @field scoped? boolean --- @field scoped? boolean
--- @field _subpriority? integer
--- @class vim.api.keyset.user_command --- @class vim.api.keyset.user_command
--- @field addr? any --- @field addr? any

View File

@ -761,32 +761,20 @@ Integer nvim_buf_set_extmark(Buffer buffer, Integer ns_id, Integer line, Integer
col2 = c; col2 = c;
} }
DecorPriority subpriority = DECOR_PRIORITY_BASE;
if (HAS_KEY(opts, set_extmark, _subpriority)) {
VALIDATE_RANGE((opts->_subpriority >= 0 && opts->_subpriority <= UINT16_MAX),
"_subpriority", {
goto error;
});
subpriority = (DecorPriority)opts->_subpriority;
}
if (kv_size(virt_text.data.virt_text)) { if (kv_size(virt_text.data.virt_text)) {
decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_text, NULL), true, decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_text, NULL), true);
subpriority);
} }
if (kv_size(virt_lines.data.virt_lines)) { if (kv_size(virt_lines.data.virt_lines)) {
decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_lines, NULL), true, decor_range_add_virt(&decor_state, r, c, line2, col2, decor_put_vt(virt_lines, NULL), true);
subpriority);
} }
if (url != NULL) { if (url != NULL) {
DecorSignHighlight sh = DECOR_SIGN_HIGHLIGHT_INIT; DecorSignHighlight sh = DECOR_SIGN_HIGHLIGHT_INIT;
sh.url = url; sh.url = url;
decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, 0, 0, subpriority); decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, 0, 0);
} }
if (has_hl) { if (has_hl) {
DecorSignHighlight sh = decor_sh_from_inline(hl); DecorSignHighlight sh = decor_sh_from_inline(hl);
decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, (uint32_t)ns_id, id, decor_range_add_sh(&decor_state, r, c, line2, col2, &sh, true, (uint32_t)ns_id, id);
subpriority);
} }
} else { } else {
if (opts->ephemeral) { if (opts->ephemeral) {

View File

@ -56,8 +56,6 @@ typedef struct {
Boolean undo_restore; Boolean undo_restore;
String url; String url;
Boolean scoped; Boolean scoped;
Integer _subpriority;
} Dict(set_extmark); } Dict(set_extmark);
typedef struct { typedef struct {

View File

@ -454,21 +454,18 @@ static void decor_range_add_from_inline(DecorState *state, int start_row, int st
if (decor.ext) { if (decor.ext) {
DecorVirtText *vt = decor.data.ext.vt; DecorVirtText *vt = decor.data.ext.vt;
while (vt) { while (vt) {
decor_range_add_virt(state, start_row, start_col, end_row, end_col, vt, owned, decor_range_add_virt(state, start_row, start_col, end_row, end_col, vt, owned);
DECOR_PRIORITY_BASE);
vt = vt->next; vt = vt->next;
} }
uint32_t idx = decor.data.ext.sh_idx; uint32_t idx = decor.data.ext.sh_idx;
while (idx != DECOR_ID_INVALID) { while (idx != DECOR_ID_INVALID) {
DecorSignHighlight *sh = &kv_A(decor_items, idx); DecorSignHighlight *sh = &kv_A(decor_items, idx);
decor_range_add_sh(state, start_row, start_col, end_row, end_col, sh, owned, ns, mark_id, decor_range_add_sh(state, start_row, start_col, end_row, end_col, sh, owned, ns, mark_id);
DECOR_PRIORITY_BASE);
idx = sh->next; idx = sh->next;
} }
} else { } else {
DecorSignHighlight sh = decor_sh_from_inline(decor.data.hl); DecorSignHighlight sh = decor_sh_from_inline(decor.data.hl);
decor_range_add_sh(state, start_row, start_col, end_row, end_col, &sh, owned, ns, mark_id, decor_range_add_sh(state, start_row, start_col, end_row, end_col, &sh, owned, ns, mark_id);
DECOR_PRIORITY_BASE);
} }
} }
@ -478,8 +475,7 @@ static void decor_range_insert(DecorState *state, DecorRange range)
size_t index; size_t index;
for (index = kv_size(state->active) - 1; index > 0; index--) { for (index = kv_size(state->active) - 1; index > 0; index--) {
DecorRange item = kv_A(state->active, index - 1); DecorRange item = kv_A(state->active, index - 1);
if ((item.priority < range.priority) if (item.priority <= range.priority) {
|| ((item.priority == range.priority) && (item.subpriority <= range.subpriority))) {
break; break;
} }
kv_A(state->active, index) = kv_A(state->active, index - 1); kv_A(state->active, index) = kv_A(state->active, index - 1);
@ -488,7 +484,7 @@ static void decor_range_insert(DecorState *state, DecorRange range)
} }
void decor_range_add_virt(DecorState *state, int start_row, int start_col, int end_row, int end_col, void decor_range_add_virt(DecorState *state, int start_row, int start_col, int end_row, int end_col,
DecorVirtText *vt, bool owned, DecorPriority subpriority) DecorVirtText *vt, bool owned)
{ {
bool is_lines = vt->flags & kVTIsLines; bool is_lines = vt->flags & kVTIsLines;
DecorRange range = { DecorRange range = {
@ -498,15 +494,13 @@ void decor_range_add_virt(DecorState *state, int start_row, int start_col, int e
.attr_id = 0, .attr_id = 0,
.owned = owned, .owned = owned,
.priority = vt->priority, .priority = vt->priority,
.subpriority = subpriority,
.draw_col = -10, .draw_col = -10,
}; };
decor_range_insert(state, range); decor_range_insert(state, range);
} }
void decor_range_add_sh(DecorState *state, int start_row, int start_col, int end_row, int end_col, void decor_range_add_sh(DecorState *state, int start_row, int start_col, int end_row, int end_col,
DecorSignHighlight *sh, bool owned, uint32_t ns, uint32_t mark_id, DecorSignHighlight *sh, bool owned, uint32_t ns, uint32_t mark_id)
DecorPriority subpriority)
{ {
if (sh->flags & kSHIsSign) { if (sh->flags & kSHIsSign) {
return; return;
@ -519,7 +513,6 @@ void decor_range_add_sh(DecorState *state, int start_row, int start_col, int end
.attr_id = 0, .attr_id = 0,
.owned = owned, .owned = owned,
.priority = sh->priority, .priority = sh->priority,
.subpriority = subpriority,
.draw_col = -10, .draw_col = -10,
}; };

View File

@ -48,8 +48,6 @@ typedef struct {
int attr_id; ///< cached lookup of inl.hl_id if it was a highlight int attr_id; ///< cached lookup of inl.hl_id if it was a highlight
bool owned; ///< ephemeral decoration, free memory immediately bool owned; ///< ephemeral decoration, free memory immediately
DecorPriority priority; DecorPriority priority;
DecorPriority subpriority; ///< Secondary priority value used for ordering (#27131).
///< Reflects the order of patterns/captures in the query file.
DecorRangeKind kind; DecorRangeKind kind;
/// Screen column to draw the virtual text. /// Screen column to draw the virtual text.
/// When -1, it should be drawn on the current screen line after deciding where. /// When -1, it should be drawn on the current screen line after deciding where.

View File

@ -727,47 +727,6 @@ describe('decorations providers', function()
n.assert_alive() n.assert_alive()
end) end)
it('supports subpriorities (order of definitions in a query file #27131)', function()
insert(mulholland)
setup_provider [[
local test_ns = api.nvim_create_namespace('mulholland')
function on_do(event, ...)
if event == "line" then
local win, buf, line = ...
api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
end_row = line + 1,
hl_eol = true,
hl_group = 'Comment',
ephemeral = true,
priority = 100,
_subpriority = 20,
})
-- This extmark is set last but has a lower subpriority, so the first extmark "wins"
api.nvim_buf_set_extmark(buf, test_ns, line, 0, {
end_row = line + 1,
hl_eol = true,
hl_group = 'String',
ephemeral = true,
priority = 100,
_subpriority = 10,
})
end
end
]]
screen:expect{grid=[[
{4:// just to see if there was an accident }|
{4:// on Mulholland Drive }|
{4:try_start(); }|
{4:bufref_T save_buf; }|
{4:switch_buffer(&save_buf, buf); }|
{4:posp = getmark(mark, false); }|
{4:restore_buffer(&save_buf);^ }|
|
]]}
end)
it('is not invoked repeatedly in Visual mode with vim.schedule() #20235', function() it('is not invoked repeatedly in Visual mode with vim.schedule() #20235', function()
exec_lua([[_G.cnt = 0]]) exec_lua([[_G.cnt = 0]])
setup_provider([[ setup_provider([[