Files
nvim-cmp/lua/cmp/utils
Greg Hurrell 5d0651c9d6 fix: don't blow up when nvim_buf_get_lines() returns Blobs (#2050)
* fix: don't blow up when `nvim_buf_get_lines()` returns Blobs

Some LSP servers may return binary garbage and `nvim_buf_get_lines()`
will return a `Blob` instead of a `String` in those cases.

I added some `print(vim.inspect())` debugging in
`entry.get_documentation()` to prove that by the time the text passes
through there, it's already garbage.

Here's an excerpt from a sample line returned by `nvim_buf_get_lines()`,
as rendered by `vim.inspect()`:

    default\0\0\0!      vim.opt.background = 'dark'\0\0\0000

(etc)

Now, this looks like an LSP bug to me, but I think we shouldn't allow
buggy LSP output to crash nvim-cmp. "Be conservative in what you send,
be liberal in what you accept" and all that.

So, degrade by coercing any `Blob` we see into a `String` before passing
it to `strdisplaywidth()`.

Closes: https://github.com/hrsh7th/nvim-cmp/issues/820

* add comment

---------

Co-authored-by: hrsh7th <629908+hrsh7th@users.noreply.github.com>
2024-10-21 20:38:46 +09:00
..
2022-05-04 01:47:01 +09:00
2022-07-24 12:44:53 +09:00
2022-07-24 12:44:53 +09:00
2022-07-24 12:44:53 +09:00
2021-08-17 16:25:19 +09:00
2023-10-18 15:37:12 +09:00
2022-05-04 12:18:09 +09:00
2022-01-31 14:16:48 +09:00
2022-04-14 02:37:21 +09:00
2021-09-11 20:18:44 +09:00
2024-03-22 18:44:52 +09:00
2021-11-15 13:11:42 +09:00
2022-04-13 23:51:55 +09:00