Skip to content

perf(source): skip opaque item data in ensure_nil - #2244

Open
hood wants to merge 2 commits into
hrsh7th:mainfrom
hood:perf/ensure-nil-skip-data
Open

hood wants to merge 2 commits into
hrsh7th:mainfrom
hood:perf/ensure-nil-skip-data

Conversation

@hood

@hood hood commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Closes #2238

Builds on #2243. Only the last commit is new here; this will rebase cleanly once #2243 is merged.

Summary

ensure_nil takes an optional set of top-level keys to skip. source.lua passes { data = true }, so the opaque CompletionItem.data goes back to the server unchanged on completionItem/resolve, as the LSP spec requires. Added a spec case for it.

Data

Time to build entries over 10 keystrokes, compared with #2243. CPU time, best of 20. Benchmark in #2236.

Scenario #2243 This PR
6k items, isIncomplete 113.6 ms 96.9 ms (-15%)
20k items, isIncomplete 378.6 ms 325.0 ms (-14%)

Behaviour

nulls inside data are kept. Every other field is handled as before, including the labelDetails case from #2212.

Testing

All 73 specs pass, luacheck reports 0 warnings, and touched files are formatted with stylua.

njhoffman added a commit to njhoffman/nvim-cmp that referenced this pull request Nov 6, 2026
Ports upstream PRs hrsh7th#2243 and hrsh7th#2244: ensure_nil works in place and skips data,
which it was altering by stripping vim.NIL values.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

perf: ensure_nil walks opaque CompletionItem.data

1 participant