diff options
author | pommicket <pommicket@gmail.com> | 2025-09-30 11:51:45 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2025-09-30 11:51:45 -0400 |
commit | f029ca734af1b4e16b7320ae2f85b3cb41b06324 (patch) | |
tree | b9db6ca1bc5304b11e38eec6a675af678aca33d0 | |
parent | fa3dbac3c18ecf3238b141e6aea1dddcb388e65b (diff) |
Fix code actions being screwed up when there are lots of options
-rw-r--r-- | ide-code-action.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/ide-code-action.c b/ide-code-action.c index edcae7c..f357e6d 100644 --- a/ide-code-action.c +++ b/ide-code-action.c @@ -105,7 +105,7 @@ bool code_action_process_lsp_response(Ted *ted, const LSPResponse *response) { // then, prefer 'quickfix' to other kinds of actions. // then, prefer whichever action comes first. int best_score = -1; - Action *best_action = NULL; + ptrdiff_t best_action = -1; arr_foreach_ptr(response->data.code_action.actions, const LSPCodeAction, action) { Action *action_out = arr_addp(c->actions); action_out->lsp = action; @@ -116,14 +116,14 @@ bool code_action_process_lsp_response(Ted *ted, const LSPResponse *response) { if (action->kind == LSP_CODE_ACTION_QUICKFIX) score += 1; if (score > best_score) { - best_action = action_out; + best_action = action_out - c->actions; best_score = score; } } - if (best_action != c->actions) { + if (best_action != -1) { // move "best" action to top - Action best = *best_action; - memmove(c->actions + 1, c->actions, (size_t)(best_action - c->actions) * sizeof *c->actions); + Action best = c->actions[best_action]; + memmove(c->actions + 1, c->actions, (size_t)best_action * sizeof *c->actions); *c->actions = best; } return true; |